aboutsummaryrefslogtreecommitdiffstats
path: root/missing
diff options
context:
space:
mode:
Diffstat (limited to 'missing')
-rw-r--r--missing/dup2.c12
-rw-r--r--missing/gcvt.c9
-rw-r--r--missing/getopt.c6
-rw-r--r--missing/memcmp.c4
-rw-r--r--missing/random.c16
-rw-r--r--missing/strcase.c10
-rw-r--r--missing/strerror.c13
-rw-r--r--missing/strftime.3259
-rw-r--r--missing/strftime.c384
-rw-r--r--missing/strtod.c5
-rw-r--r--missing/strtol.c120
-rw-r--r--missing/system.c7
-rw-r--r--missing/tmpnam.c27
-rw-r--r--missing/tzset.c38
-rw-r--r--missing/vprintf.c9
15 files changed, 841 insertions, 78 deletions
diff --git a/missing/dup2.c b/missing/dup2.c
deleted file mode 100644
index 01068348..00000000
--- a/missing/dup2.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef F_DUPFD
-#include <fcntl.h>
-#endif
-
-int
-dup2 (old, new)
-int old, new;
-{
- (void) close(new);
-
- return fcntl(old, F_DUPFD, new);
-}
diff --git a/missing/gcvt.c b/missing/gcvt.c
deleted file mode 100644
index 1ebe41e1..00000000
--- a/missing/gcvt.c
+++ /dev/null
@@ -1,9 +0,0 @@
-char *
-gcvt(value, digits, buff)
-double value;
-int digits;
-char *buff;
-{
- sprintf(buff, "%*g", digits, value);
- return (buff);
-}
diff --git a/missing/getopt.c b/missing/getopt.c
index d9e52945..09a1b233 100644
--- a/missing/getopt.c
+++ b/missing/getopt.c
@@ -14,7 +14,7 @@
* 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
+ * 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.
@@ -22,12 +22,14 @@
* However, I am not about to post a copy of anything licensed by AT&T.
*/
-#if defined(MSDOS) || defined(USG)
+#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();\
diff --git a/missing/memcmp.c b/missing/memcmp.c
index e39c10ec..63cb5f8f 100644
--- a/missing/memcmp.c
+++ b/missing/memcmp.c
@@ -10,9 +10,9 @@ memcmp (s1, s2, l)
register char *s1, *s2;
register int l;
{
- for (; l--; s1++, s2++) {
+ for (; l-- > 0; s1++, s2++) {
if (*s1 != *s2)
return (*s1 - *s2);
}
- return (*--s1 - *--s2);
+ return (0);
}
diff --git a/missing/random.c b/missing/random.c
index 3708fe90..3cd675e4 100644
--- a/missing/random.c
+++ b/missing/random.c
@@ -19,7 +19,9 @@
static char sccsid[] = "@(#)random.c 5.5 (Berkeley) 7/6/88";
#endif /* LIBC_SCCS and not lint */
+#if 0
#include <stdio.h>
+#endif
/*
* random.c:
@@ -87,6 +89,10 @@ static char sccsid[] = "@(#)random.c 5.5 (Berkeley) 7/6/88";
#define BREAK_3 128
#define DEG_3 31
#define SEP_3 3
+#ifdef _CRAY
+#define DEG_3_P1 32 /* bug - do addition here */
+#define SEP_3_P1 4 /* *_3 + 1 = _3_P1 */
+#endif
#define TYPE_4 4 /* x**63 + x + 1 */
#define BREAK_4 256
@@ -142,7 +148,11 @@ static long randtbl[ DEG_3 + 1 ] = { TYPE_3,
* to point to randtbl[1] (as explained below).
*/
+#ifdef _CRAY
+static long *fptr = &randtbl[ SEP_3_P1 ];
+#else
static long *fptr = &randtbl[ SEP_3 + 1 ];
+#endif
static long *rptr = &randtbl[ 1 ];
@@ -165,7 +175,11 @@ static int rand_type = TYPE_3;
static int rand_deg = DEG_3;
static int rand_sep = SEP_3;
+#ifdef _CRAY
+static long *end_ptr = &randtbl[ DEG_3_P1 ];
+#else
static long *end_ptr = &randtbl[ DEG_3 + 1 ];
+#endif
@@ -236,7 +250,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 0;
+ return;
}
rand_type = TYPE_0;
rand_deg = DEG_0;
diff --git a/missing/strcase.c b/missing/strcase.c
index d8fa674a..6834f27d 100644
--- a/missing/strcase.c
+++ b/missing/strcase.c
@@ -19,11 +19,7 @@
static char sccsid[] = "@(#)strcasecmp.c 5.6 (Berkeley) 6/27/88";
#endif /* LIBC_SCCS and not lint */
-#ifndef USG
-#include <sys/types.h>
-#else
#define u_char unsigned char
-#endif
/*
* This array is designed for mapping upper and lower case letter
@@ -55,10 +51,10 @@ static u_char charmap[] = {
'\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
'\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
'\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
- '\300', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
+ '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
'\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
- '\370', '\371', '\372', '\333', '\334', '\335', '\336', '\337',
+ '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\327',
+ '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\337',
'\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
'\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
'\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
diff --git a/missing/strerror.c b/missing/strerror.c
index e9c20804..badaf5dd 100644
--- a/missing/strerror.c
+++ b/missing/strerror.c
@@ -3,15 +3,15 @@
*/
/*
- * Copyright (C) 1986, 1988, 1989 the Free Software Foundation, Inc.
+ * 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 1, or (at your option)
- * any later version.
+ * 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
@@ -20,17 +20,12 @@
*
* 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, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
extern int sys_nerr;
extern char *sys_errlist[];
-/* have to get right decl of sprintf early on */
-#ifndef BUFSIZ /* stdio specific definition */
-#include <stdio.h>
-#endif
-
char *
strerror(n)
int n;
diff --git a/missing/strftime.3 b/missing/strftime.3
new file mode 100644
index 00000000..b61ed029
--- /dev/null
+++ b/missing/strftime.3
@@ -0,0 +1,259 @@
+.TH STRFTIME 3
+.SH NAME
+strftime \- generate formatted time information
+.SH SYNOPSIS
+.ft B
+.nf
+#include <sys/types.h>
+#include <time.h>
+.sp
+size_t strftime(char *s, size_t maxsize, const char *format,
+ const struct tm *timeptr);
+.SH DESCRIPTION
+The following description is transcribed verbatim from the December 7, 1988
+draft standard for ANSI C.
+This draft is essentially identical in technical content
+to the final version of the standard.
+.LP
+The
+.B strftime
+function places characters into the array pointed to by
+.B s
+as controlled by the string pointed to by
+.BR format .
+The format shall be a multibyte character sequence, beginning and ending in
+its initial shift state.
+The
+.B format
+string consists of zero or more conversion specifiers and ordinary
+multibyte characters. A conversion specifier consists of a
+.B %
+character followed by a character that determines the behavior of the
+conversion specifier.
+All ordinary multibyte characters (including the terminating null
+character) are copied unchanged into the array.
+If copying takes place between objects that overlap the behavior is undefined.
+No more than
+.B maxsize
+characters are placed into the array.
+Each conversion specifier is replaced by appropriate characters as described
+in the following list.
+The appropriate characters are determined by the
+.B LC_TIME
+category of the current locale and by the values contained in the
+structure pointed to by
+.BR timeptr .
+.TP
+.B %a
+is replaced by the locale's abbreviated weekday name.
+.TP
+.B %A
+is replaced by the locale's full weekday name.
+.TP
+.B %b
+is replaced by the locale's abbreviated month name.
+.TP
+.B %B
+is replaced by the locale's full month name.
+.TP
+.B %c
+is replaced by the locale's appropriate date and time representation.
+.TP
+.B %d
+is replaced by the day of the month as a decimal number
+.RB ( 01 - 31 ).
+.TP
+.B %H
+is replaced by the hour (24-hour clock) as a decimal number
+.RB ( 00 - 23 ).
+.TP
+.B %I
+is replaced by the hour (12-hour clock) as a decimal number
+.RB ( 01 - 12 ).
+.TP
+.B %j
+is replaced by the day of the year as a decimal number
+.RB ( 001 - 366 ).
+.TP
+.B %m
+is replaced by the month as a decimal number
+.RB ( 01 - 12 ).
+.TP
+.B %M
+is replaced by the minute as a decimal number
+.RB ( 00 - 59 ).
+.TP
+.B %p
+is replaced by the locale's equivalent of the AM/PM designations associated
+with a 12-hour clock.
+.TP
+.B %S
+is replaced by the second as a decimal number
+.RB ( 00 - 61 ).
+.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 ).
+.TP
+.B %w
+is replaced by the weekday as a decimal number
+.RB [ "0 " (Sunday)- 6 ].
+.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 ).
+.TP
+.B %x
+is replaced by the locale's appropriate date representation.
+.TP
+.B %X
+is replaced by the locale's appropriate time representation.
+.TP
+.B %y
+is replaced by the year without century as a decimal number
+.RB ( 00 - 99 ).
+.TP
+.B %Y
+is replaced by the year with century as a decimal number.
+.TP
+.B %Z
+is replaced by the time zone name or abbreviation, or by no characters if
+no time zone is determinable.
+.TP
+.B %%
+is replaced by
+.BR % .
+.LP
+If a conversion specifier is not one of the above, the behavior is
+undefined.
+.SH RETURNS
+If the total number of resulting characters including the terminating null
+character is not more than
+.BR maxsize ,
+the
+.B strftime
+function returns the number of characters placed into the array pointed to
+by
+.B s
+not including the terminating null character.
+Otherwise, zero is returned and the contents of the array are indeterminate.
+.SH NON-ANSI EXTENSIONS
+If
+.B SYSV_EXT
+is defined when the routine is compiled, then the following additional
+conversions will be available.
+These are borrowed from the System V
+.IR cftime (3)
+and
+.IR ascftime (3)
+routines.
+.TP
+.B %D
+is equivalent to specifying
+.BR %m/%d/%y .
+.TP
+.B %e
+is replaced by the day of the month,
+padded with a blank if it is only one digit.
+.TP
+.B %h
+is equivalent to
+.BR %b ,
+above.
+.TP
+.B %n
+is replaced with a newline character (\s-1ASCII LF\s+1).
+.TP
+.B %r
+is equivalent to specifying
+.BR "%I:%M:%S %p" .
+.TP
+.B %R
+is equivalent to specifying
+.BR %H:%M .
+.TP
+.B %T
+is equivalent to specifying
+.BR %H:%M:%S .
+.TP
+.B %t
+is replaced with a \s-1TAB\s+1 character.
+.SH POSIX 1003.2 EXTENSIONS
+If
+.B POSIX2_DATE
+is defined, then all of the conversions available with
+.B SYSV_EXT
+are available, as well as the
+following additional conversions:
+.TP
+.B %C
+The century, as a number between 00 and 99.
+.LP
+In additon, the alternate representations
+.BR %Ec ,
+.BR %EC ,
+.BR %Ex ,
+.BR %Ey ,
+.BR %EY ,
+.BR %Od ,
+.BR %Oe ,
+.BR %OH ,
+.BR %OI ,
+.BR %Om ,
+.BR %OM ,
+.BR %OS ,
+.BR %OU ,
+.BR %Ow ,
+.BR %OW ,
+and
+.B %Oy
+are recognized, but their normal representations are used.
+.SH VMS EXTENSIONS
+If
+.B VMS_EXT
+is defined, then the following additional conversion is available:
+.TP
+.B %V
+The date in VMS format (e.g. 20-JUN-1991).
+.SH SEE ALSO
+time(2), ctime(3), localtime(3)
+.SH BUGS
+This version does not handle multibyte characters or pay attention to the
+setting of the
+.B LC_TIME
+environment variable.
+.LP
+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
+.IR tzset (3)
+exactly once. If 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.
+.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
+.fi
+.SH ACKNOWLEDGEMENTS
+Thanks to Geoff Clare <gwc@root.co.uk> for helping debug earlier
+versions of this routine.
+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
new file mode 100644
index 00000000..11f41ce9
--- /dev/null
+++ b/missing/strftime.c
@@ -0,0 +1,384 @@
+/*
+ * strftime.c
+ *
+ * Public-domain relatively quick-and-dirty implemenation of
+ * ANSI library routine for System V Unix systems.
+ *
+ * It's written in old-style C for maximal portability.
+ * However, since I'm used to prototypes, I've included them too.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * Arnold Robbins
+ * January, February, March, 1991
+ *
+ * Fixes from ado@elsie.nci.nih.gov
+ * February 1991
+ */
+
+#if 0
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <time.h>
+#include <sys/types.h>
+#endif
+
+#ifndef __STDC__
+#define const /**/
+#endif
+
+#ifndef __STDC__
+extern void tzset();
+extern char *strchr();
+static int weeknumber();
+#else
+extern void tzset(void);
+extern char *strchr(const char *str, int ch);
+static int weeknumber(const struct tm *timeptr, int firstweekday);
+#endif
+
+#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 */
+
+#if defined(POSIX2_DATE) && ! defined(SYSV_EXT)
+#define SYSV_EXT 1
+#endif
+
+/* strftime --- produce formatted time */
+
+#ifndef __STDC__
+size_t
+strftime(s, maxsize, format, timeptr)
+char *s;
+size_t maxsize;
+const char *format;
+const struct tm *timeptr;
+#else
+size_t
+strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr)
+#endif
+{
+ char *endp = s + maxsize;
+ char *start = s;
+ char tbuf[100];
+ int i;
+ static short first = 1;
+
+ /* various tables, useful in North America */
+ static char *days_a[] = {
+ "Sun", "Mon", "Tue", "Wed",
+ "Thu", "Fri", "Sat",
+ };
+ static char *days_l[] = {
+ "Sunday", "Monday", "Tuesday", "Wednesday",
+ "Thursday", "Friday", "Saturday",
+ };
+ static char *months_a[] = {
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
+ };
+ static char *months_l[] = {
+ "January", "February", "March", "April",
+ "May", "June", "July", "August", "September",
+ "October", "November", "December",
+ };
+ static char *ampm[] = { "AM", "PM", };
+
+ if (s == NULL || format == NULL || timeptr == NULL || maxsize == 0)
+ return 0;
+
+ if (strchr(format, '%') == NULL && strlen(format) + 1 >= maxsize)
+ return 0;
+
+ if (first) {
+ tzset();
+ first = 0;
+ }
+
+ for (; *format && s < endp - 1; format++) {
+ tbuf[0] = '\0';
+ if (*format != '%') {
+ *s++ = *format;
+ continue;
+ }
+ again:
+ switch (*++format) {
+ case '\0':
+ *s++ = '%';
+ goto out;
+
+ case '%':
+ *s++ = '%';
+ continue;
+
+ case 'a': /* abbreviated weekday name */
+ if (timeptr->tm_wday < 0 || timeptr->tm_wday > 6)
+ strcpy(tbuf, "?");
+ else
+ strcpy(tbuf, days_a[timeptr->tm_wday]);
+ break;
+
+ case 'A': /* full weekday name */
+ if (timeptr->tm_wday < 0 || timeptr->tm_wday > 6)
+ strcpy(tbuf, "?");
+ else
+ strcpy(tbuf, days_l[timeptr->tm_wday]);
+ break;
+
+#ifdef SYSV_EXT
+ case 'h': /* abbreviated month name */
+#endif
+ case 'b': /* abbreviated month name */
+ if (timeptr->tm_mon < 0 || timeptr->tm_mon > 11)
+ strcpy(tbuf, "?");
+ else
+ strcpy(tbuf, months_a[timeptr->tm_mon]);
+ break;
+
+ case 'B': /* full month name */
+ if (timeptr->tm_mon < 0 || timeptr->tm_mon > 11)
+ strcpy(tbuf, "?");
+ else
+ strcpy(tbuf, months_l[timeptr->tm_mon]);
+ break;
+
+ 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,
+ timeptr->tm_year + 1900);
+ break;
+
+ case 'd': /* day of the month, 01 - 31 */
+ sprintf(tbuf, "%02d", timeptr->tm_mday);
+ break;
+
+ case 'H': /* hour, 24-hour clock, 00 - 23 */
+ sprintf(tbuf, "%02d", timeptr->tm_hour);
+ break;
+
+ case 'I': /* hour, 12-hour clock, 01 - 12 */
+ i = timeptr->tm_hour;
+ if (i == 0)
+ i = 12;
+ else if (i > 12)
+ i -= 12;
+ sprintf(tbuf, "%02d", i);
+ break;
+
+ case 'j': /* day of the year, 001 - 366 */
+ sprintf(tbuf, "%03d", timeptr->tm_yday + 1);
+ break;
+
+ case 'm': /* month, 01 - 12 */
+ sprintf(tbuf, "%02d", timeptr->tm_mon + 1);
+ break;
+
+ case 'M': /* minute, 00 - 59 */
+ sprintf(tbuf, "%02d", timeptr->tm_min);
+ break;
+
+ case 'p': /* am or pm based on 12-hour clock */
+ if (timeptr->tm_hour < 12)
+ strcpy(tbuf, ampm[0]);
+ else
+ strcpy(tbuf, ampm[1]);
+ break;
+
+ case 'S': /* second, 00 - 61 */
+ sprintf(tbuf, "%02d", timeptr->tm_sec);
+ break;
+
+ case 'U': /* week of year, Sunday is first day of week */
+ sprintf(tbuf, "%d", weeknumber(timeptr, 0));
+ break;
+
+ case 'w': /* weekday, Sunday == 0, 0 - 6 */
+ sprintf(tbuf, "%d", timeptr->tm_wday);
+ break;
+
+ case 'W': /* week of year, Monday is first day of week */
+ sprintf(tbuf, "%d", weeknumber(timeptr, 1));
+ break;
+
+ case 'x': /* appropriate date representation */
+ sprintf(tbuf, "%s %s %2d %d",
+ days_a[timeptr->tm_wday],
+ months_a[timeptr->tm_mon],
+ timeptr->tm_mday,
+ timeptr->tm_year + 1900);
+ break;
+
+ case 'X': /* appropriate time representation */
+ sprintf(tbuf, "%02d:%02d:%02d",
+ timeptr->tm_hour,
+ timeptr->tm_min,
+ timeptr->tm_sec);
+ break;
+
+ case 'y': /* year without a century, 00 - 99 */
+ i = timeptr->tm_year % 100;
+ sprintf(tbuf, "%d", i);
+ break;
+
+ case 'Y': /* year with century */
+ sprintf(tbuf, "%d", 1900 + timeptr->tm_year);
+ break;
+
+ case 'Z': /* time zone name or abbrevation */
+ i = 0;
+ if (
+#ifndef TZNAME_MISSING
+ daylight &&
+#endif
+ timeptr->tm_isdst)
+ i = 1;
+#ifdef TZNAME_MISSING
+ strcpy(tbuf, timeptr->tm_zone);
+#else
+ strcpy(tbuf, tzname[i]);
+#endif
+ break;
+
+#ifdef SYSV_EXT
+ case 'n': /* same as \n */
+ tbuf[0] = '\n';
+ tbuf[1] = '\0';
+ break;
+
+ case 't': /* same as \t */
+ tbuf[0] = '\t';
+ tbuf[1] = '\0';
+ break;
+
+ case 'D': /* date as %m/%d/%y */
+ strftime(tbuf, sizeof tbuf, "%m/%d/%y", timeptr);
+ break;
+
+ case 'e': /* day of month, blank padded */
+ sprintf(tbuf, "%2d", timeptr->tm_mday);
+ break;
+
+ case 'r': /* time as %I:%M:%S %p */
+ strftime(tbuf, sizeof tbuf, "%I:%M:%S %p", timeptr);
+ break;
+
+ case 'R': /* time as %H:%M */
+ strftime(tbuf, sizeof tbuf, "%H:%M", timeptr);
+ break;
+
+ case 'T': /* time as %H:%M:%S */
+ strftime(tbuf, sizeof tbuf, "%H:%M:%S", timeptr);
+ break;
+#endif
+
+
+#ifdef VMS_EXT
+ case 'V': /* date as dd-bbb-YYYY */
+ sprintf(tbuf, "%2d-%3.3s-%4d",
+ timeptr->tm_mday,
+ months_a[timeptr->tm_mon],
+ timeptr->tm_year + 1900);
+ for (i = 3; i < 6; i++)
+ if (islower(tbuf[i]))
+ tbuf[i] = toupper(tbuf[i]);
+ break;
+#endif
+
+
+#ifdef POSIX2_DATE
+ case 'C':
+ sprintf(tbuf, "%02d", (timeptr->tm_year + 1900) / 100);
+ break;
+
+
+ case 'E':
+ case 'O':
+ /* POSIX locale extensions, ignored for now */
+ goto again;
+#endif
+ default:
+ tbuf[0] = '%';
+ tbuf[1] = *format;
+ tbuf[2] = '\0';
+ break;
+ }
+ i = strlen(tbuf);
+ if (i)
+ if (s + i < endp - 1) {
+ strcpy(s, tbuf);
+ s += i;
+ } else
+ return 0;
+ }
+out:
+ if (s < endp && *format == '\0') {
+ *s = '\0';
+ return (s - start);
+ } else
+ return 0;
+}
+
+/* weeknumber --- figure how many weeks into the year */
+
+/* With thanks and tip of the hatlo to ado@elsie.nci.nih.gov */
+
+#ifndef __STDC__
+static int
+weeknumber(timeptr, firstweekday)
+const struct tm *timeptr;
+int firstweekday;
+#else
+static int
+weeknumber(const struct tm *timeptr, int firstweekday)
+#endif
+{
+ if (firstweekday == 0)
+ return (timeptr->tm_yday + 7 - timeptr->tm_wday) / 7;
+ else
+ return (timeptr->tm_yday + 7 -
+ (timeptr->tm_wday ? (timeptr->tm_wday - 1) : 6)) / 7;
+}
+
+#if 0
+/* ADR --- I'm loathe to mess with ado's code ... */
+
+Date: Wed, 24 Apr 91 20:54:08 MDT
+From: Michal Jaegermann <audfax!emory!vm.ucs.UAlberta.CA!NTOMCZAK>
+To: arnold@audiofax.com
+
+Hi Arnold,
+in a process of fixing of strftime() in libraries on Atari ST I grabbed
+some pieces of code from your own strftime. When doing that it came
+to mind that your weeknumber() function compiles a little bit nicer
+in the following form:
+/*
+ * firstweekday is 0 if starting in Sunday, non-zero if in Monday
+ */
+{
+ return (timeptr->tm_yday - timeptr->tm_wday +
+ (firstweekday ? (timeptr->tm_wday ? 8 : 1) : 7)) / 7;
+}
+How nicer it depends on a compiler, of course, but always a tiny bit.
+
+ Cheers,
+ Michal
+ ntomczak@vm.ucs.ualberta.ca
+#endif
diff --git a/missing/strtod.c b/missing/strtod.c
index 79350a1e..38c7ce50 100644
--- a/missing/strtod.c
+++ b/missing/strtod.c
@@ -21,13 +21,16 @@
* This bought us a 10% speedup on a sample program at uunet.uu.net.
*/
+#if 0
#include <ctype.h>
+#endif
extern double atof();
double
strtod (s, ptr)
-register char *s, **ptr;
+register const char *s;
+register char **ptr;
{
double ret = 0.0;
char *start = s;
diff --git a/missing/strtol.c b/missing/strtol.c
new file mode 100644
index 00000000..e102ae34
--- /dev/null
+++ b/missing/strtol.c
@@ -0,0 +1,120 @@
+/*
+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
new file mode 100644
index 00000000..bceca9e9
--- /dev/null
+++ b/missing/system.c
@@ -0,0 +1,7 @@
+int
+system(s)
+char *s;
+{
+ fatal("system() not supported on this system");
+ return 0;
+}
diff --git a/missing/tmpnam.c b/missing/tmpnam.c
deleted file mode 100644
index 8f49859a..00000000
--- a/missing/tmpnam.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * tmpnam - an implementation for systems lacking a library version
- * this version does not rely on the P_tmpdir and L_tmpnam constants.
- */
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-static char template[] = "/tmp/gawkXXXXXX";
-
-char *
-tmpnam(tmp)
-char *tmp;
-{
- static char tmpbuf[sizeof(template)];
-
- if (tmp == NULL) {
- (void) strcpy(tmpbuf, template);
- (void) mktemp(tmpbuf);
- return tmpbuf;
- } else {
- (void) strcpy(tmp, template);
- (void) mktemp(tmp);
- return tmp;
- }
-}
diff --git a/missing/tzset.c b/missing/tzset.c
new file mode 100644
index 00000000..7e0af48a
--- /dev/null
+++ b/missing/tzset.c
@@ -0,0 +1,38 @@
+/*
+ * tzset.c
+ *
+ * Quick and dirty emulation of tzset(), tzname[], and daylight
+ * for old BSD systems without it.
+ *
+ * Thanks to Rick Adams, rick@uunet.uu.net, for the basics.
+ *
+ * BUGS:
+ * Totally ignores the value of the TZ environment variable.
+ */
+
+#if 0
+#include <sys/time.h>
+#endif
+
+static char tz1[1024];
+static char tz2[1024];
+
+/* external variables */
+char *tzname[2] = {
+ tz1, tz2
+};
+int daylight;
+
+extern char *timezone();
+
+void
+tzset()
+{
+ struct timeval tp;
+ struct timezone tz;
+
+ (void) gettimeofday(&tp, &tz);
+ (void) strcpy(tz1, timezone(tz.tz_minuteswest, 0));
+ (void) strcpy(tz2, timezone(tz.tz_minuteswest, 1));
+ daylight = tz.tz_dsttime;
+}
diff --git a/missing/vprintf.c b/missing/vprintf.c
index dea4ca86..bfa529e8 100644
--- a/missing/vprintf.c
+++ b/missing/vprintf.c
@@ -1,11 +1,4 @@
-#include <stdio.h>
-#include <varargs.h>
-
-#ifndef BUFSIZ
-#include <stdio.h>
-#endif
-
-#ifndef va_dcl
+#if 0
#include <varargs.h>
#endif