blob: 85b13251fd41ca2f11aa2ac8e0136e0ffd9e31c6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/* Provide definitions for missing or incorrect libc functions. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef 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;
}
#endif
#ifndef 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];
}
#endif
#ifdef 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.
(Originally, we suspected strtol too, but it seems to work, at least in
NeXTSTEP 3.3 patch 2.) */
double
good_strtod(const char *nptr, char **endptr)
{
double d = strtod(nptr, endptr);
if (endptr)
while (*endptr > nptr && isspace((*endptr)[-1]))
(*endptr)--;
return d;
}
#endif
#ifdef __cplusplus
}
#endif
|