diff options
Diffstat (limited to 'Build/source/texk/lcdf-typetools/liblcdf/fixlibc.c')
-rw-r--r-- | Build/source/texk/lcdf-typetools/liblcdf/fixlibc.c | 57 |
1 files changed, 33 insertions, 24 deletions
diff --git a/Build/source/texk/lcdf-typetools/liblcdf/fixlibc.c b/Build/source/texk/lcdf-typetools/liblcdf/fixlibc.c index 5d0b831c613..d41238daf85 100644 --- a/Build/source/texk/lcdf-typetools/liblcdf/fixlibc.c +++ b/Build/source/texk/lcdf-typetools/liblcdf/fixlibc.c @@ -10,38 +10,38 @@ extern "C" { #endif -#ifndef HAVE_STRDUP +#if !HAVE_STRDUP char * strdup(const char *s) { - char *t; - int l; - if (!s) - return 0; - l = strlen(s) + 1; - t = (char *)malloc(l); - if (!t) - return 0; - memcpy(t, s, l); - return t; + char *t; + int l; + if (!s) + return 0; + l = strlen(s) + 1; + t = (char *)malloc(l); + if (!t) + return 0; + memcpy(t, s, l); + return t; } #endif -#ifndef HAVE_STRERROR +#if !HAVE_STRERROR /* David Mazieres <dm@lcs.mit.edu> assures me that this definition works. */ char * strerror(int errno) { - extern int sys_nerr; - extern char *sys_errlist[]; - if (errno < 0 || errno >= sys_nerr) - return (char *)"bad error number"; - else - return sys_errlist[errno]; + extern int sys_nerr; + extern char *sys_errlist[]; + if (errno < 0 || errno >= sys_nerr) + return (char *)"bad error number"; + else + return sys_errlist[errno]; } #endif -#ifdef BROKEN_STRTOD +#if HAVE_BROKEN_STRTOD /* On NeXTSTEP, Melissa O'Neill <oneill@cs.sfu.ca> reports that strtod consumes whitespace after its argument, which makes mminstance (among other programs) not work. This wrapper gets rid of that whitespace again. @@ -51,11 +51,20 @@ strerror(int errno) double good_strtod(const char *nptr, char **endptr) { - double d = strtod(nptr, endptr); - if (endptr) - while (*endptr > nptr && isspace((unsigned char) (*endptr)[-1])) - (*endptr)--; - return d; + double d = strtod(nptr, endptr); + if (endptr) + while (*endptr > nptr && isspace((unsigned char) (*endptr)[-1])) + (*endptr)--; + return d; +} +#endif + +#if !HAVE_STRNLEN || HAVE_BROKEN_STRNLEN +size_t +strnlen(const char *s, size_t maxlen) +{ + const char *p = (const char *) memchr(s, 0, maxlen); + return p ? p - s : maxlen; } #endif |