diff options
Diffstat (limited to 'missing')
-rw-r--r-- | missing/getopt.c | 93 | ||||
-rw-r--r-- | missing/random.c | 3 | ||||
-rw-r--r-- | missing/strcase.c | 12 | ||||
-rw-r--r-- | missing/strftime.3 | 78 | ||||
-rw-r--r-- | missing/strftime.c | 250 | ||||
-rw-r--r-- | missing/strtod.c | 2 | ||||
-rw-r--r-- | missing/strtol.c | 120 | ||||
-rw-r--r-- | missing/system.c | 25 | ||||
-rw-r--r-- | missing/vprintf.c | 47 |
9 files changed, 308 insertions, 322 deletions
diff --git a/missing/getopt.c b/missing/getopt.c deleted file mode 100644 index 09a1b233..00000000 --- a/missing/getopt.c +++ /dev/null @@ -1,93 +0,0 @@ -/* -** @(#)getopt.c 2.5 (smail) 9/15/87 -*/ - -/* - * Here's something you've all been waiting for: the AT&T public domain - * source for getopt(3). It is the code which was given out at the 1985 - * UNIFORUM conference in Dallas. I obtained it by electronic mail - * directly from AT&T. The people there assure me that it is indeed - * in the public domain. - * - * There is no manual page. That is because the one they gave out at - * UNIFORUM was slightly different from the current System V Release 2 - * manual page. The difference apparently involved a note about the - * famous rules 5 and 6, recommending using white space between an option - * and its first argument, and not grouping options that have arguments. - * Getopt itself is currently lenient about both of these things. White - * space is allowed, but not mandatory, and the last option in a group can - * have an argument. That particular version of the man page evidently - * has no official existence, and my source at AT&T did not send a copy. - * The current SVR2 man page reflects the actual behavor of this getopt. - * However, I am not about to post a copy of anything licensed by AT&T. - */ - -#if defined(__STDC__) || defined(USG) || defined(MSDOS) || defined(VMS) -#define index strchr -#endif - -/*LINTLIBRARY*/ -#ifndef NULL -#define NULL 0 -#endif -#define EOF (-1) -#define ERR(s, c) if(opterr){\ - extern int write();\ - char errbuf[2];\ - errbuf[0] = c; errbuf[1] = '\n';\ - (void) write(2, argv[0], (unsigned)strlen(argv[0]));\ - (void) write(2, s, (unsigned)strlen(s));\ - (void) write(2, errbuf, 2);} - -extern char *index(); - -int opterr = 1; -int optind = 1; -int optopt; -char *optarg; - -int -getopt(argc, argv, opts) -int argc; -char **argv, *opts; -{ - static int sp = 1; - register int c; - register char *cp; - - if(sp == 1) - if(optind >= argc || - argv[optind][0] != '-' || argv[optind][1] == '\0') - return(EOF); - else if(strcmp(argv[optind], "--") == NULL) { - optind++; - return(EOF); - } - optopt = c = argv[optind][sp]; - if(c == ':' || (cp=index(opts, c)) == NULL) { - ERR(": illegal option -- ", c); - if(argv[optind][++sp] == '\0') { - optind++; - sp = 1; - } - return('?'); - } - if(*++cp == ':') { - if(argv[optind][sp+1] != '\0') - optarg = &argv[optind++][sp+1]; - else if(++optind >= argc) { - ERR(": option requires an argument -- ", c); - sp = 1; - return('?'); - } else - optarg = argv[optind++]; - sp = 1; - } else { - if(argv[optind][++sp] == '\0') { - sp = 1; - optind++; - } - optarg = NULL; - } - return(c); -} diff --git a/missing/random.c b/missing/random.c index 3cd675e4..16e598ae 100644 --- a/missing/random.c +++ b/missing/random.c @@ -196,6 +196,7 @@ static long *end_ptr = &randtbl[ DEG_3 + 1 ]; * values produced by this routine. */ +void srandom( x ) unsigned x; @@ -250,7 +251,7 @@ initstate( seed, arg_state, n ) if( n < BREAK_1 ) { if( n < BREAK_0 ) { fprintf( stderr, "initstate: not enough state (%d bytes) with which to do jack; ignored.\n", n ); - return; + return 0; } rand_type = TYPE_0; rand_deg = DEG_0; diff --git a/missing/strcase.c b/missing/strcase.c index 6834f27d..5d93911f 100644 --- a/missing/strcase.c +++ b/missing/strcase.c @@ -61,8 +61,9 @@ static u_char charmap[] = { '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377', }; +int strcasecmp(s1, s2) - char *s1, *s2; + const char *s1, *s2; { register u_char *cm = charmap, *us1 = (u_char *)s1, @@ -74,16 +75,17 @@ strcasecmp(s1, s2) return(cm[*us1] - cm[*--us2]); } +int strncasecmp(s1, s2, n) - char *s1, *s2; - register int n; + const char *s1, *s2; + register size_t n; { register u_char *cm = charmap, *us1 = (u_char *)s1, *us2 = (u_char *)s2; - while (--n >= 0 && cm[*us1] == cm[*us2++]) + while ((long)(--n) >= 0 && cm[*us1] == cm[*us2++]) if (*us1++ == '\0') return(0); - return(n < 0 ? 0 : cm[*us1] - cm[*--us2]); + return((long)n < 0 ? 0 : cm[*us1] - cm[*--us2]); } diff --git a/missing/strftime.3 b/missing/strftime.3 index b61ed029..254db661 100644 --- a/missing/strftime.3 +++ b/missing/strftime.3 @@ -190,8 +190,47 @@ following additional conversions: .TP .B %C The century, as a number between 00 and 99. +.TP +.B %u +is replaced by the weekday as a decimal number +.RB [ "1 " (Monday)- 7 ]. +.TP +.B %V +is replaced by the week number of the year (the first Monday as the first +day of week 1) as a decimal number +.RB ( 01 - 53 ). +The method for determining the week number is as specified by ISO 8601 +(to wit: if the week containing January 1 has four or more days in the +new year, then it is week 1, otherwise it is week 53 of the previous year +and the next week is week 1). +.LP +The text of the POSIX standard for the +.I date +utility describes +.B %U +and +.B %W +this way: +.TP +.B %U +is replaced by the week number of the year (the first Sunday as the first +day of week 1) as a decimal number +.RB ( 00 - 53 ). +All days in a new year preceding the first Sunday are considered to be +in week 0. +.TP +.B %W +is replaced by the week number of the year (the first Monday as the first +day of week 1) as a decimal number +.RB ( 00 - 53 ). +All days in a new year preceding the first Sunday are considered to be +in week 0. +(Note: this last statement is quoted verbatim from the POSIX standard. +It probably means to say ``all days in a new year preceding the first +.I Monday +are considered to be in week 0.'') .LP -In additon, the alternate representations +In addition, the alternate representations .BR %Ec , .BR %EC , .BR %Ex , @@ -204,7 +243,9 @@ In additon, the alternate representations .BR %Om , .BR %OM , .BR %OS , +.BR %Ou , .BR %OU , +.BR %OV , .BR %Ow , .BR %OW , and @@ -215,7 +256,7 @@ If .B VMS_EXT is defined, then the following additional conversion is available: .TP -.B %V +.B %v The date in VMS format (e.g. 20-JUN-1991). .SH SEE ALSO time(2), ctime(3), localtime(3) @@ -228,32 +269,27 @@ environment variable. It is not clear what is ``appropriate'' for the C locale; the values returned are a best guess on the author's part. .SH CAVEATS -This implementation calls +The pre-processor symbol +.B POSIX_SEMANTICS +is automatically defined, which forces the code to call .IR tzset (3) -exactly once. If the +whenever the .B TZ -environment variable is changed after -.B strftime -has been called, then -.IR tzset (3) -must be called again, explicitly, in order for the -correct timezone information to be available. +environment variable has changed. +If this routine will be used in an application that will not be changing +.BR TZ , +then there may be some performance improvements by not defining +.BR POSIX_SEMANTICS . .SH AUTHOR .nf Arnold Robbins -AudioFAX, Inc. -Suite 200 -2000 Powers Ferry Road -Marietta, GA. 30067 -U.S.A. -INTERNET: arnold@audiofax.com -UUCP: emory!audfax!arnold -Phone: +1 404 618 4281 -Fax-box: +1 404 618 4581 +.sp +INTERNET: arnold@skeeve.atl.ga.us +UUCP: emory!skeeve!arnold +Phone: +1 404 248 9324 .fi .SH ACKNOWLEDGEMENTS Thanks to Geoff Clare <gwc@root.co.uk> for helping debug earlier -versions of this routine. +versions of this routine, and for advice about POSIX semantics. Additional thanks to Arthur David Olsen <ado@elsie.nci.nih.gov> for some code improvements. - diff --git a/missing/strftime.c b/missing/strftime.c index 11f41ce9..da696a8d 100644 --- a/missing/strftime.c +++ b/missing/strftime.c @@ -9,53 +9,109 @@ * * If you want stuff in the System V ascftime routine, add the SYSV_EXT define. * For stuff needed to implement the P1003.2 date command, add POSIX2_DATE. + * For complete POSIX semantics, add POSIX_SEMANTICS. * * The code for %c, %x, and %X is my best guess as to what's "appropriate". * This version ignores LOCALE information. * It also doesn't worry about multi-byte characters. * So there. * + * This file is also shipped with GAWK (GNU Awk), gawk specific bits of + * code are included if GAWK is defined. + * * Arnold Robbins * January, February, March, 1991 + * Updated March, April 1992 * * Fixes from ado@elsie.nci.nih.gov - * February 1991 + * February 1991, May 1992 */ -#if 0 +#ifndef GAWK #include <stdio.h> -#include <string.h> #include <ctype.h> +#include <string.h> #include <time.h> #include <sys/types.h> #endif -#ifndef __STDC__ -#define const /**/ +/* defaults: season to taste */ +#define SYSV_EXT 1 /* stuff in System V ascftime routine */ +#define POSIX2_DATE 1 /* stuff in Posix 1003.2 date command */ +#define VMS_EXT 1 /* include %v for VMS date format */ +#ifndef GAWK +#define POSIX_SEMANTICS 1 /* call tzset() if TZ changes */ +#endif + +#if defined(POSIX2_DATE) && ! defined(SYSV_EXT) +#define SYSV_EXT 1 +#endif + +#if defined(POSIX2_DATE) +#define adddecl(stuff) stuff +#else +#define adddecl(stuff) #endif #ifndef __STDC__ +#define const /**/ +extern void *malloc(); +extern void *realloc(); extern void tzset(); extern char *strchr(); +extern char *getenv(); static int weeknumber(); +adddecl(static int iso8601wknum();) #else +extern void *malloc(unsigned count); +extern void *realloc(void *ptr, unsigned count); extern void tzset(void); extern char *strchr(const char *str, int ch); +extern char *getenv(const char *v); static int weeknumber(const struct tm *timeptr, int firstweekday); +adddecl(static int iso8601wknum(const struct tm *timeptr);) #endif +#ifdef __GNUC__ +#define inline __inline__ +#else +#define inline /**/ +#endif + +#define range(low, item, hi) max(low, min(item, hi)) + #if !defined(MSDOS) && !defined(TZNAME_MISSING) extern char *tzname[2]; extern int daylight; #endif -#define SYSV_EXT 1 /* stuff in System V ascftime routine */ -#define POSIX2_DATE 1 /* stuff in Posix 1003.2 date command */ -#define VMS_EXT 1 /* include %V for VMS date format */ +/* min --- return minimum of two numbers */ -#if defined(POSIX2_DATE) && ! defined(SYSV_EXT) -#define SYSV_EXT 1 +#ifndef __STDC__ +static inline int +min(a, b) +int a, b; +#else +static inline int +min(int a, int b) +#endif +{ + return (a < b ? a : b); +} + +/* max --- return maximum of two numbers */ + +#ifndef __STDC__ +static inline int +max(a, b) +int a, b; +#else +static inline int +max(int a, int b) #endif +{ + return (a > b ? a : b); +} /* strftime --- produce formatted time */ @@ -76,6 +132,12 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr) char tbuf[100]; int i; static short first = 1; +#ifdef POSIX_SEMANTICS + static char *savetz = NULL; + static int savetzlen = 0; + char *tz; + int tzlen; +#endif /* various tables, useful in North America */ static char *days_a[] = { @@ -103,10 +165,39 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr) if (strchr(format, '%') == NULL && strlen(format) + 1 >= maxsize) return 0; +#ifndef POSIX_SEMANTICS if (first) { tzset(); first = 0; } +#else /* POSIX_SEMANTICS */ + tz = getenv("TZ"); + tzlen = strlen(tz); + if (first) { + if (tz != NULL) { + savetz = (char *) malloc(tzlen + 1); + if (savetz != NULL) { + savetzlen = tzlen + 1; + strcpy(savetz, tz); + } + } + tzset(); + first = 0; + } + /* if we have a saved TZ, and it is different, recapture and reset */ + if (tz && savetz && (tz[0] != savetz[0] || strcmp(tz, savetz) != 0)) { + i = strlen(tz) + 1; + if (i > savetzlen) { + savetz = (char *) realloc(savetz, i); + if (savetz) { + savetzlen = i; + strcpy(savetz, tz); + } + } else + strcpy(savetz, tz); + tzset(); + } +#endif /* POSIX_SEMANTICS */ for (; *format && s < endp - 1; format++) { tbuf[0] = '\0'; @@ -157,25 +248,27 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr) case 'c': /* appropriate date and time representation */ sprintf(tbuf, "%s %s %2d %02d:%02d:%02d %d", - days_a[timeptr->tm_wday], - months_a[timeptr->tm_mon], - timeptr->tm_mday, - timeptr->tm_hour, - timeptr->tm_min, - timeptr->tm_sec, + days_a[range(0, timeptr->tm_wday, 6)], + months_a[range(0, timeptr->tm_mon, 11)], + range(1, timeptr->tm_mday, 31), + range(0, timeptr->tm_hour, 23), + range(0, timeptr->tm_min, 59), + range(0, timeptr->tm_sec, 61), timeptr->tm_year + 1900); break; case 'd': /* day of the month, 01 - 31 */ - sprintf(tbuf, "%02d", timeptr->tm_mday); + i = range(1, timeptr->tm_mday, 31); + sprintf(tbuf, "%02d", i); break; case 'H': /* hour, 24-hour clock, 00 - 23 */ - sprintf(tbuf, "%02d", timeptr->tm_hour); + i = range(0, timeptr->tm_hour, 23); + sprintf(tbuf, "%02d", i); break; case 'I': /* hour, 12-hour clock, 01 - 12 */ - i = timeptr->tm_hour; + i = range(0, timeptr->tm_hour, 23); if (i == 0) i = 12; else if (i > 12) @@ -188,22 +281,26 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr) break; case 'm': /* month, 01 - 12 */ - sprintf(tbuf, "%02d", timeptr->tm_mon + 1); + i = range(0, timeptr->tm_mon, 11); + sprintf(tbuf, "%02d", i + 1); break; case 'M': /* minute, 00 - 59 */ - sprintf(tbuf, "%02d", timeptr->tm_min); + i = range(0, timeptr->tm_min, 59); + sprintf(tbuf, "%02d", i); break; case 'p': /* am or pm based on 12-hour clock */ - if (timeptr->tm_hour < 12) + i = range(0, timeptr->tm_hour, 23); + if (i < 12) strcpy(tbuf, ampm[0]); else strcpy(tbuf, ampm[1]); break; case 'S': /* second, 00 - 61 */ - sprintf(tbuf, "%02d", timeptr->tm_sec); + i = range(0, timeptr->tm_sec, 61); + sprintf(tbuf, "%02d", i); break; case 'U': /* week of year, Sunday is first day of week */ @@ -211,7 +308,8 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr) break; case 'w': /* weekday, Sunday == 0, 0 - 6 */ - sprintf(tbuf, "%d", timeptr->tm_wday); + i = range(0, timeptr->tm_wday, 6); + sprintf(tbuf, "%d", i); break; case 'W': /* week of year, Monday is first day of week */ @@ -220,17 +318,17 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr) case 'x': /* appropriate date representation */ sprintf(tbuf, "%s %s %2d %d", - days_a[timeptr->tm_wday], - months_a[timeptr->tm_mon], - timeptr->tm_mday, + days_a[range(0, timeptr->tm_wday, 6)], + months_a[range(0, timeptr->tm_mon, 11)], + range(1, timeptr->tm_mday, 31), timeptr->tm_year + 1900); break; case 'X': /* appropriate time representation */ sprintf(tbuf, "%02d:%02d:%02d", - timeptr->tm_hour, - timeptr->tm_min, - timeptr->tm_sec); + range(0, timeptr->tm_hour, 23), + range(0, timeptr->tm_min, 59), + range(0, timeptr->tm_sec, 61)); break; case 'y': /* year without a century, 00 - 99 */ @@ -273,7 +371,7 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr) break; case 'e': /* day of month, blank padded */ - sprintf(tbuf, "%2d", timeptr->tm_mday); + sprintf(tbuf, "%2d", range(1, timeptr->tm_mday, 31)); break; case 'r': /* time as %I:%M:%S %p */ @@ -291,10 +389,10 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr) #ifdef VMS_EXT - case 'V': /* date as dd-bbb-YYYY */ + case 'v': /* date as dd-bbb-YYYY */ sprintf(tbuf, "%2d-%3.3s-%4d", - timeptr->tm_mday, - months_a[timeptr->tm_mon], + range(1, timeptr->tm_mday, 31), + months_a[range(0, timeptr->tm_mon, 11)], timeptr->tm_year + 1900); for (i = 3; i < 6; i++) if (islower(tbuf[i])) @@ -313,7 +411,30 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr) case 'O': /* POSIX locale extensions, ignored for now */ goto again; + + case 'V': /* week of year according ISO 8601 */ +#if defined(GAWK) && defined(VMS_EXT) + { + extern int do_lint; + extern void warning(); + static int warned = 0; + + if (! warned && do_lint) { + warned = 1; + warning( + "conversion %%V added in P1003.2/11.3; for VMS style date, use %%v"); + } + } #endif + sprintf(tbuf, "%d", iso8601wknum(timeptr)); + break; + + case 'u': + /* ISO 8601: Weekday as a decimal number [1 (Monday) - 7] */ + sprintf(tbuf, "%d", timeptr->tm_wday == 0 ? 7 : + timeptr->tm_wday); + break; +#endif /* POSIX2_DATE */ default: tbuf[0] = '%'; tbuf[1] = *format; @@ -336,6 +457,67 @@ out: return 0; } +#ifdef POSIX2_DATE +/* iso8601wknum --- compute week number according to ISO 8601 */ + +#ifndef __STDC__ +static int +iso8601wknum(timeptr) +const struct tm *timeptr; +#else +static int +iso8601wknum(const struct tm *timeptr) +#endif +{ + /* + * From 1003.2 D11.3: + * If the week (Monday to Sunday) containing January 1 + * has four or more days in the new year, then it is week 1; + * otherwise it is week 53 of the previous year, and the + * next week is week 1. + * + * ADR: This means if Jan 1 was Monday through Thursday, + * it was week 1, otherwise week 53. + */ + + int simple_wknum, jan1day, diff, ret; + + /* get week number, Monday as first day of the week */ + simple_wknum = weeknumber(timeptr, 1) + 1; + + /* + * With thanks and tip of the hatlo to ado@elsie.nci.nih.gov + * + * What day of the week does January 1 fall on? + * We know that + * (timeptr->tm_yday - jan1.tm_yday) MOD 7 == + * (timeptr->tm_wday - jan1.tm_wday) MOD 7 + * and that + * jan1.tm_yday == 1 + * and that + * timeptr->tm_wday MOD 7 == timeptr->tm_wday + * from which it follows that. . . + */ + jan1day = (timeptr->tm_yday - 1) % 7 - timeptr->tm_wday; + if (jan1day < 0) + jan1day += 7; + + /* + * If Jan 1 was a Monday through Thursday, it was in + * week 1. Otherwise it was last year's week 53, which is + * this year's week 0. + */ + if (jan1day >= 1 && jan1day <= 4) + diff = 0; + else + diff = 1; + ret = simple_wknum - diff; + if (ret == 0) /* we're in the first week of the year */ + ret = 53; + return ret; +} +#endif + /* weeknumber --- figure how many weeks into the year */ /* With thanks and tip of the hatlo to ado@elsie.nci.nih.gov */ diff --git a/missing/strtod.c b/missing/strtod.c index 38c7ce50..746a5da9 100644 --- a/missing/strtod.c +++ b/missing/strtod.c @@ -29,7 +29,7 @@ extern double atof(); double strtod (s, ptr) -register const char *s; +register char *s; register char **ptr; { double ret = 0.0; diff --git a/missing/strtol.c b/missing/strtol.c deleted file mode 100644 index e102ae34..00000000 --- a/missing/strtol.c +++ /dev/null @@ -1,120 +0,0 @@ -/* -Article 4291 of comp.lang.c: -From: chris@mimsy.umd.edu (Chris Torek) -Newsgroups: comp.lang.c -Subject: Re: error checking strtol -Message-ID: <24445@mimsy.umd.edu> -Date: 17 May 90 09:31:17 GMT -Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 - -The following is a working strtol. It depends only on the existence of -correct header files (including <limits.h>) and on ASCII (IBM programmers -will have to use strchr()). It does not support locales other than `C'. -System V programmers should be able to replace their current strtol with -this one. (After writing this, I checked the SVR2 source; it did not -handle several cases correctly.) -*/ - -#ifdef __STDC__ -#include <limits.h> -#else -#define LONG_MIN (-0x80000000) /* for 32-bit 2s-complement at least */ -#define LONG_MAX 0x7fffffff -#endif - -#if 0 -#include <limits.h> -#include <ctype.h> -#include <errno.h> -#endif - -#ifndef _MSC_VER -int errno; -#endif - -/* - * Convert a string to a long integer. - * - * Ignores `locale' stuff. Assumes that the upper and lower case - * alphabets and digits are each contiguous. - */ -long -strtol(nptr, endptr, base) - const char *nptr; - char **endptr; - register int base; -{ - register const char *s = nptr; - register unsigned long acc; - register int c; - register unsigned long cutoff; - register int neg = 0, any, cutlim; - - /* - * Skip white space and pick up leading +/- sign if any. - * If base is 0, allow 0x for hex and 0 for octal, else - * assume decimal; if base is already 16, allow 0x. - */ - do { - c = *s++; - } while (isspace(c)); - if (c == '-') { - neg = 1; - c = *s++; - } else if (c == '+') - c = *s++; - if ((base == 0 || base == 16) && - c == '0' && (*s == 'x' || *s == 'X')) { - c = s[1]; - s += 2; - base = 16; - } - if (base == 0) - base = c == '0' ? 8 : 10; - - /* - * Compute the cutoff value between legal numbers and illegal - * numbers. That is the largest legal value, divided by the - * base. An input number that is greater than this value, if - * followed by a legal input character, is too big. One that - * is equal to this value may be valid or not; the limit - * between valid and invalid numbers is then based on the last - * digit. For instance, if the range for longs is - * [-2147483648..2147483647] and the input base is 10, - * cutoff will be set to 214748364 and cutlim to either - * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated - * a value > 214748364, or equal but the next digit is > 7 (or 8), - * the number is too big, and we will return a range error. - * - * Set any if any `digits' consumed; make it negative to indicate - * overflow. - */ - cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX; - cutlim = cutoff % (unsigned long)base; - cutoff /= (unsigned long)base; - for (acc = 0, any = 0;; c = *s++) { - if (isdigit(c)) - c -= '0'; - else if (isalpha(c)) - c -= isupper(c) ? 'A' - 10 : 'a' - 10; - else - break; - if (c >= base) - break; - if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim) - any = -1; - else { - any = 1; - acc *= base; - acc += c; - } - } - if (any < 0) { - acc = neg ? LONG_MIN : LONG_MAX; - errno = ERANGE; - } else if (neg) - acc = -acc; - if (endptr != 0) - *endptr = (char *) (any ? s - 1 : nptr); - return (acc); -} diff --git a/missing/system.c b/missing/system.c index bceca9e9..a062917a 100644 --- a/missing/system.c +++ b/missing/system.c @@ -1,3 +1,28 @@ +/* + * system.c --- replacement system() for systems missing one + */ + +/* + * Copyright (C) 1986, 1988, 1989, 1991 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Progamming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GAWK; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + int system(s) char *s; diff --git a/missing/vprintf.c b/missing/vprintf.c deleted file mode 100644 index bfa529e8..00000000 --- a/missing/vprintf.c +++ /dev/null @@ -1,47 +0,0 @@ -#if 0 -#include <varargs.h> -#endif - -int -vsprintf(str, fmt, ap) - char *str, *fmt; - va_list ap; -{ - FILE f; - int len; - - f._flag = _IOWRT+_IOSTRG; - f._ptr = (char *)str; /* My copy of BSD stdio.h has this as (char *) - * with a comment that it should be - * (unsigned char *). Since this code is - * intended for use on a vanilla BSD system, - * we'll stick with (char *) for now. - */ - f._cnt = 32767; - len = _doprnt(fmt, ap, &f); - *f._ptr = 0; - return (len); -} - -int -vfprintf(iop, fmt, ap) - FILE *iop; - char *fmt; - va_list ap; -{ - int len; - - len = _doprnt(fmt, ap, iop); - return (ferror(iop) ? EOF : len); -} - -int -vprintf(fmt, ap) - char *fmt; - va_list ap; -{ - int len; - - len = _doprnt(fmt, ap, stdout); - return (ferror(stdout) ? EOF : len); -} |