From 15bda956325f7804589f59d06bba2641b486ebf8 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 12 Oct 1993 01:50:00 +0000 Subject: [PATCH] GNU shell utilities --- lib/basename.c | 11 +++++++++++ lib/getdate.y | 2 +- lib/mktime.c | 37 ++++++++++++++++++++++--------------- lib/posixtm.y | 13 ++++++++++++- 4 files changed, 46 insertions(+), 17 deletions(-) diff --git a/lib/basename.c b/lib/basename.c index 4a2a5411cc..2244e13934 100644 --- a/lib/basename.c +++ b/lib/basename.c @@ -15,6 +15,17 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#ifdef HAVE_CONFIG_H +#if defined (CONFIG_BROKETS) +/* We use instead of "config.h" so that a compilation + using -I. -I will use ./config.h rather than /config.h + (which it would do because it found this file in ). */ +#include +#else +#include "config.h" +#endif +#endif + #if defined(STDC_HEADERS) || defined(HAVE_STRING_H) #include #ifndef rindex diff --git a/lib/getdate.y b/lib/getdate.y index e5cf18a16b..e15a886a0c 100644 --- a/lib/getdate.y +++ b/lib/getdate.y @@ -41,7 +41,7 @@ #ifdef _AIX /* for Bison */ #pragma alloca #else -char *alloca (); +void *alloca (); #endif #endif #endif diff --git a/lib/mktime.c b/lib/mktime.c index db4474b019..591da9fd3d 100644 --- a/lib/mktime.c +++ b/lib/mktime.c @@ -19,8 +19,15 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifdef HAVE_CONFIG_H +#if defined (CONFIG_BROKETS) +/* We use instead of "config.h" so that a compilation + using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h + (which it would do because it found this file in $srcdir). */ +#include +#else #include "config.h" #endif +#endif #include /* Some systems define `time_t' here. */ #include @@ -96,14 +103,14 @@ dist_tm (t1, t2) else if (t1->x > t2->x) \ diff_flag = 1; \ } - + doit (tm_year, 31536000); /* Okay, not all years have 365 days. */ doit (tm_mon, 2592000); /* Okay, not all months have 30 days. */ doit (tm_mday, 86400); doit (tm_hour, 3600); doit (tm_min, 60); doit (tm_sec, 1); - + #undef doit distance = v1 - v2; @@ -118,7 +125,7 @@ dist_tm (t1, t2) return distance; } - + /* Modified binary search -- make intelligent guesses as to where the time might lie along the timeline, assuming that our target time lies a @@ -142,7 +149,7 @@ search (target) guess += distance; guess_tm = localtime (&guess); - + #ifdef DEBUG if (debugging_enabled) { @@ -151,7 +158,7 @@ search (target) puts (""); } #endif - + /* Are we on the money? */ distance = dist_tm (target, guess_tm); @@ -176,7 +183,7 @@ mktime (timeptr) time_t result; me = &private_mktime_struct_tm; - + *me = *timeptr; #define normalize(foo,x,y,bar); \ @@ -190,11 +197,11 @@ mktime (timeptr) me->bar++; \ me->foo = (x + (me->foo - y)); \ } - + normalize (tm_sec, 0, 59, tm_min); normalize (tm_min, 0, 59, tm_hour); normalize (tm_hour, 0, 23, tm_mday); - + /* Do the month first, so day range can be found. */ normalize (tm_mon, 0, 11, tm_year); normalize (tm_mday, 1, @@ -208,7 +215,7 @@ mktime (timeptr) normalize (tm_mday, 1, __mon_lengths[__isleap (me->tm_year)][me->tm_mon], tm_mon); - + #ifdef DEBUG if (debugging_enabled) { @@ -234,11 +241,11 @@ main (argc, argv) int time; int result_time; struct tm *tmptr; - + if (argc == 1) { long q; - + printf ("starting long test...\n"); for (q = 10000000; q < 1000000000; q++) @@ -248,23 +255,23 @@ main (argc, argv) if (q != my_mktime (tm)) { printf ("failed for %ld\n", q); fflush (stdout); } } - + printf ("test finished\n"); exit (0); } - + if (argc != 2) { printf ("wrong # of args\n"); exit (0); } - + debugging_enabled = 1; /* we want to see the info */ ++argv; time = atoi (*argv); - + printf ("Time: %d %s\n", time, ctime (&time)); tmptr = localtime (&time); diff --git a/lib/posixtm.y b/lib/posixtm.y index 0967667b8d..ea81ef134f 100644 --- a/lib/posixtm.y +++ b/lib/posixtm.y @@ -26,11 +26,22 @@ #ifdef _AIX #pragma alloca #else -char *alloca (); +void *alloca (); #endif #endif #endif +#ifdef HAVE_CONFIG_H +#if defined (CONFIG_BROKETS) +/* We use instead of "config.h" so that a compilation + using -I. -I will use ./config.h rather than /config.h + (which it would do because it found this file in ). */ +#include +#else +#include "config.h" +#endif +#endif + #include #include -- 2.39.5