Check for predefined strlcpy (as in newer gcc versions)
This commit is contained in:
@@ -5,8 +5,6 @@
|
||||
|
||||
Contents: Header file for mxml.c
|
||||
|
||||
$Id$
|
||||
|
||||
\********************************************************************/
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
Contents: Contains strlcpy and strlcat which are versions of
|
||||
strcpy and strcat, but which avoid buffer overflows
|
||||
|
||||
$Id:$
|
||||
|
||||
\********************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -19,6 +17,8 @@
|
||||
* will be copied. Always NUL terminates (unless size == 0).
|
||||
* Returns strlen(src); if retval >= siz, truncation occurred.
|
||||
*/
|
||||
#ifndef STRLCPY_DEFINED
|
||||
|
||||
size_t strlcpy(char *dst, const char *src, size_t size)
|
||||
{
|
||||
char *d = dst;
|
||||
@@ -80,3 +80,5 @@ size_t strlcat(char *dst, const char *src, size_t size)
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------*/
|
||||
|
||||
#endif // STRLCPY_DEFINED
|
||||
|
||||
@@ -5,13 +5,16 @@
|
||||
|
||||
Contents: Header file for strlcpy.c
|
||||
|
||||
$Id$
|
||||
|
||||
\********************************************************************/
|
||||
|
||||
#ifndef _STRLCPY_H_
|
||||
#define _STRLCPY_H_
|
||||
|
||||
// some version of gcc have a built-in strlcpy
|
||||
#ifdef strlcpy
|
||||
#define STRLCPY_DEFINED
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -24,8 +27,10 @@ extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef STRLCPY_DEFINED
|
||||
size_t EXPRT strlcpy(char *dst, const char *src, size_t size);
|
||||
size_t EXPRT strlcat(char *dst, const char *src, size_t size);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user