diff options
author | Thorsten Lockert <tholo@cvs.openbsd.org> | 1998-02-22 08:56:11 +0000 |
---|---|---|
committer | Thorsten Lockert <tholo@cvs.openbsd.org> | 1998-02-22 08:56:11 +0000 |
commit | e8befda30be9497912a351c5f2bb0b3d0a8257f9 (patch) | |
tree | fc964c412f584dff1e3c8b45784a9d25e301b686 /gnu/usr.bin/cvs/lib | |
parent | 26a78b7b0ee68653084708a1dddba75fd9918291 (diff) |
Integrate local changes
Diffstat (limited to 'gnu/usr.bin/cvs/lib')
-rw-r--r-- | gnu/usr.bin/cvs/lib/getdate.c | 116 | ||||
-rw-r--r-- | gnu/usr.bin/cvs/lib/getdate.y | 32 | ||||
-rw-r--r-- | gnu/usr.bin/cvs/lib/getwd.c | 35 | ||||
-rw-r--r-- | gnu/usr.bin/cvs/lib/strdup.c | 43 |
4 files changed, 94 insertions, 132 deletions
diff --git a/gnu/usr.bin/cvs/lib/getdate.c b/gnu/usr.bin/cvs/lib/getdate.c index d4d93506e90..c97fd30af03 100644 --- a/gnu/usr.bin/cvs/lib/getdate.c +++ b/gnu/usr.bin/cvs/lib/getdate.c @@ -14,7 +14,6 @@ static char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; ** at the University of North Carolina at Chapel Hill. Later tweaked by ** a couple of people on Usenet. Completely overhauled by Rich $alz ** <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990; -** send any email to Rich. ** ** This grammar has 10 shift/reduce conflicts. ** @@ -185,12 +184,12 @@ static MERIDIAN yyMeridian; static time_t yyRelMonth; static time_t yyRelSeconds; -#line 180 "../../work/ccvs/lib/getdate.y" +#line 179 "../../work/ccvs/lib/getdate.y" typedef union { time_t Number; enum _MERIDIAN Meridian; } YYSTYPE; -#line 194 "y.tab.c" +#line 193 "y.tab.c" #define tAGO 257 #define tDAY 258 #define tDAYZONE 259 @@ -403,7 +402,7 @@ YYSTYPE yylval; short yyss[YYSTACKSIZE]; YYSTYPE yyvs[YYSTACKSIZE]; #define yystacksize YYSTACKSIZE -#line 393 "../../work/ccvs/lib/getdate.y" +#line 392 "../../work/ccvs/lib/getdate.y" /* Month and day table. */ static TABLE const MonthDayTable[] = { @@ -618,10 +617,14 @@ ToSeconds(Hours, Minutes, Seconds, Meridian) case MERam: if (Hours < 1 || Hours > 12) return -1; + if (Hours == 12) + Hours = 0; return (Hours * 60L + Minutes) * 60L + Seconds; case MERpm: if (Hours < 1 || Hours > 12) return -1; + if (Hours == 12) + Hours = 0; return ((Hours + 12) * 60L + Minutes) * 60L + Seconds; default: abort (); @@ -927,17 +930,34 @@ get_date(p, now) yyInput = p; if (now == NULL) { + struct tm *gmt_ptr; + now = &ftz; (void)time (&nowtime); - if (! (tm = gmtime (&nowtime))) - return -1; - gmt = *tm; /* Make a copy, in case localtime modifies *tm. */ + gmt_ptr = gmtime (&nowtime); + if (gmt_ptr != NULL) + { + /* Make a copy, in case localtime modifies *tm (I think + that comment now applies to *gmt_ptr, but I am too + lazy to dig into how gmtime and locatime allocate the + structures they return pointers to). */ + gmt = *gmt_ptr; + } if (! (tm = localtime (&nowtime))) return -1; - - ftz.timezone = difftm (&gmt, tm) / 60; + + if (gmt_ptr != NULL) + ftz.timezone = difftm (&gmt, tm) / 60; + else + /* We are on a system like VMS, where the system clock is + in local time and the system has no concept of timezones. + Hopefully we can fake this out (for the case in which the + user specifies no timezone) by just saying the timezone + is zero. */ + ftz.timezone = 0; + if(tm->tm_isdst) ftz.timezone += 60; } @@ -1020,7 +1040,7 @@ main(ac, av) /* NOTREACHED */ } #endif /* defined(TEST) */ -#line 1024 "y.tab.c" +#line 1044 "y.tab.c" #define YYABORT goto yyabort #define YYREJECT goto yyabort #define YYACCEPT goto yyaccept @@ -1162,37 +1182,37 @@ yyreduce: switch (yyn) { case 3: -#line 198 "../../work/ccvs/lib/getdate.y" +#line 197 "../../work/ccvs/lib/getdate.y" { yyHaveTime++; } break; case 4: -#line 201 "../../work/ccvs/lib/getdate.y" +#line 200 "../../work/ccvs/lib/getdate.y" { yyHaveZone++; } break; case 5: -#line 204 "../../work/ccvs/lib/getdate.y" +#line 203 "../../work/ccvs/lib/getdate.y" { yyHaveDate++; } break; case 6: -#line 207 "../../work/ccvs/lib/getdate.y" +#line 206 "../../work/ccvs/lib/getdate.y" { yyHaveDay++; } break; case 7: -#line 210 "../../work/ccvs/lib/getdate.y" +#line 209 "../../work/ccvs/lib/getdate.y" { yyHaveRel++; } break; case 9: -#line 216 "../../work/ccvs/lib/getdate.y" +#line 215 "../../work/ccvs/lib/getdate.y" { yyHour = yyvsp[-1].Number; yyMinutes = 0; @@ -1201,7 +1221,7 @@ case 9: } break; case 10: -#line 222 "../../work/ccvs/lib/getdate.y" +#line 221 "../../work/ccvs/lib/getdate.y" { yyHour = yyvsp[-3].Number; yyMinutes = yyvsp[-1].Number; @@ -1210,7 +1230,7 @@ case 10: } break; case 11: -#line 228 "../../work/ccvs/lib/getdate.y" +#line 227 "../../work/ccvs/lib/getdate.y" { yyHour = yyvsp[-3].Number; yyMinutes = yyvsp[-1].Number; @@ -1220,7 +1240,7 @@ case 11: } break; case 12: -#line 235 "../../work/ccvs/lib/getdate.y" +#line 234 "../../work/ccvs/lib/getdate.y" { yyHour = yyvsp[-5].Number; yyMinutes = yyvsp[-3].Number; @@ -1229,7 +1249,7 @@ case 12: } break; case 13: -#line 241 "../../work/ccvs/lib/getdate.y" +#line 240 "../../work/ccvs/lib/getdate.y" { yyHour = yyvsp[-5].Number; yyMinutes = yyvsp[-3].Number; @@ -1240,56 +1260,56 @@ case 13: } break; case 14: -#line 251 "../../work/ccvs/lib/getdate.y" +#line 250 "../../work/ccvs/lib/getdate.y" { yyTimezone = yyvsp[0].Number; yyDSTmode = DSToff; } break; case 15: -#line 255 "../../work/ccvs/lib/getdate.y" +#line 254 "../../work/ccvs/lib/getdate.y" { yyTimezone = yyvsp[0].Number; yyDSTmode = DSTon; } break; case 16: -#line 260 "../../work/ccvs/lib/getdate.y" +#line 259 "../../work/ccvs/lib/getdate.y" { yyTimezone = yyvsp[-1].Number; yyDSTmode = DSTon; } break; case 17: -#line 266 "../../work/ccvs/lib/getdate.y" +#line 265 "../../work/ccvs/lib/getdate.y" { yyDayOrdinal = 1; yyDayNumber = yyvsp[0].Number; } break; case 18: -#line 270 "../../work/ccvs/lib/getdate.y" +#line 269 "../../work/ccvs/lib/getdate.y" { yyDayOrdinal = 1; yyDayNumber = yyvsp[-1].Number; } break; case 19: -#line 274 "../../work/ccvs/lib/getdate.y" +#line 273 "../../work/ccvs/lib/getdate.y" { yyDayOrdinal = yyvsp[-1].Number; yyDayNumber = yyvsp[0].Number; } break; case 20: -#line 280 "../../work/ccvs/lib/getdate.y" +#line 279 "../../work/ccvs/lib/getdate.y" { yyMonth = yyvsp[-2].Number; yyDay = yyvsp[0].Number; } break; case 21: -#line 284 "../../work/ccvs/lib/getdate.y" +#line 283 "../../work/ccvs/lib/getdate.y" { yyMonth = yyvsp[-4].Number; yyDay = yyvsp[-2].Number; @@ -1297,7 +1317,7 @@ case 21: } break; case 22: -#line 289 "../../work/ccvs/lib/getdate.y" +#line 288 "../../work/ccvs/lib/getdate.y" { /* ISO 8601 format. yyyy-mm-dd. */ yyYear = yyvsp[-2].Number; @@ -1306,7 +1326,7 @@ case 22: } break; case 23: -#line 295 "../../work/ccvs/lib/getdate.y" +#line 294 "../../work/ccvs/lib/getdate.y" { /* e.g. 17-JUN-1992. */ yyDay = yyvsp[-2].Number; @@ -1315,14 +1335,14 @@ case 23: } break; case 24: -#line 301 "../../work/ccvs/lib/getdate.y" +#line 300 "../../work/ccvs/lib/getdate.y" { yyMonth = yyvsp[-1].Number; yyDay = yyvsp[0].Number; } break; case 25: -#line 305 "../../work/ccvs/lib/getdate.y" +#line 304 "../../work/ccvs/lib/getdate.y" { yyMonth = yyvsp[-3].Number; yyDay = yyvsp[-2].Number; @@ -1330,14 +1350,14 @@ case 25: } break; case 26: -#line 310 "../../work/ccvs/lib/getdate.y" +#line 309 "../../work/ccvs/lib/getdate.y" { yyMonth = yyvsp[0].Number; yyDay = yyvsp[-1].Number; } break; case 27: -#line 314 "../../work/ccvs/lib/getdate.y" +#line 313 "../../work/ccvs/lib/getdate.y" { yyMonth = yyvsp[-1].Number; yyDay = yyvsp[-2].Number; @@ -1345,68 +1365,68 @@ case 27: } break; case 28: -#line 321 "../../work/ccvs/lib/getdate.y" +#line 320 "../../work/ccvs/lib/getdate.y" { yyRelSeconds = -yyRelSeconds; yyRelMonth = -yyRelMonth; } break; case 30: -#line 328 "../../work/ccvs/lib/getdate.y" +#line 327 "../../work/ccvs/lib/getdate.y" { yyRelSeconds += yyvsp[-1].Number * yyvsp[0].Number * 60L; } break; case 31: -#line 331 "../../work/ccvs/lib/getdate.y" +#line 330 "../../work/ccvs/lib/getdate.y" { yyRelSeconds += yyvsp[-1].Number * yyvsp[0].Number * 60L; } break; case 32: -#line 334 "../../work/ccvs/lib/getdate.y" +#line 333 "../../work/ccvs/lib/getdate.y" { yyRelSeconds += yyvsp[0].Number * 60L; } break; case 33: -#line 337 "../../work/ccvs/lib/getdate.y" +#line 336 "../../work/ccvs/lib/getdate.y" { yyRelSeconds += yyvsp[-1].Number; } break; case 34: -#line 340 "../../work/ccvs/lib/getdate.y" +#line 339 "../../work/ccvs/lib/getdate.y" { yyRelSeconds += yyvsp[-1].Number; } break; case 35: -#line 343 "../../work/ccvs/lib/getdate.y" +#line 342 "../../work/ccvs/lib/getdate.y" { yyRelSeconds++; } break; case 36: -#line 346 "../../work/ccvs/lib/getdate.y" +#line 345 "../../work/ccvs/lib/getdate.y" { yyRelMonth += yyvsp[-1].Number * yyvsp[0].Number; } break; case 37: -#line 349 "../../work/ccvs/lib/getdate.y" +#line 348 "../../work/ccvs/lib/getdate.y" { yyRelMonth += yyvsp[-1].Number * yyvsp[0].Number; } break; case 38: -#line 352 "../../work/ccvs/lib/getdate.y" +#line 351 "../../work/ccvs/lib/getdate.y" { yyRelMonth += yyvsp[0].Number; } break; case 39: -#line 357 "../../work/ccvs/lib/getdate.y" +#line 356 "../../work/ccvs/lib/getdate.y" { if (yyHaveTime && yyHaveDate && !yyHaveRel) yyYear = yyvsp[0].Number; @@ -1434,18 +1454,18 @@ case 39: } break; case 40: -#line 384 "../../work/ccvs/lib/getdate.y" +#line 383 "../../work/ccvs/lib/getdate.y" { yyval.Meridian = MER24; } break; case 41: -#line 387 "../../work/ccvs/lib/getdate.y" +#line 386 "../../work/ccvs/lib/getdate.y" { yyval.Meridian = yyvsp[0].Meridian; } break; -#line 1449 "y.tab.c" +#line 1469 "y.tab.c" } yyssp -= yym; yystate = *yyssp; diff --git a/gnu/usr.bin/cvs/lib/getdate.y b/gnu/usr.bin/cvs/lib/getdate.y index 8ed565caacc..fdb177d04c1 100644 --- a/gnu/usr.bin/cvs/lib/getdate.y +++ b/gnu/usr.bin/cvs/lib/getdate.y @@ -4,7 +4,6 @@ ** at the University of North Carolina at Chapel Hill. Later tweaked by ** a couple of people on Usenet. Completely overhauled by Rich $alz ** <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990; -** send any email to Rich. ** ** This grammar has 10 shift/reduce conflicts. ** @@ -604,10 +603,14 @@ ToSeconds(Hours, Minutes, Seconds, Meridian) case MERam: if (Hours < 1 || Hours > 12) return -1; + if (Hours == 12) + Hours = 0; return (Hours * 60L + Minutes) * 60L + Seconds; case MERpm: if (Hours < 1 || Hours > 12) return -1; + if (Hours == 12) + Hours = 0; return ((Hours + 12) * 60L + Minutes) * 60L + Seconds; default: abort (); @@ -913,17 +916,34 @@ get_date(p, now) yyInput = p; if (now == NULL) { + struct tm *gmt_ptr; + now = &ftz; (void)time (&nowtime); - if (! (tm = gmtime (&nowtime))) - return -1; - gmt = *tm; /* Make a copy, in case localtime modifies *tm. */ + gmt_ptr = gmtime (&nowtime); + if (gmt_ptr != NULL) + { + /* Make a copy, in case localtime modifies *tm (I think + that comment now applies to *gmt_ptr, but I am too + lazy to dig into how gmtime and locatime allocate the + structures they return pointers to). */ + gmt = *gmt_ptr; + } if (! (tm = localtime (&nowtime))) return -1; - - ftz.timezone = difftm (&gmt, tm) / 60; + + if (gmt_ptr != NULL) + ftz.timezone = difftm (&gmt, tm) / 60; + else + /* We are on a system like VMS, where the system clock is + in local time and the system has no concept of timezones. + Hopefully we can fake this out (for the case in which the + user specifies no timezone) by just saying the timezone + is zero. */ + ftz.timezone = 0; + if(tm->tm_isdst) ftz.timezone += 60; } diff --git a/gnu/usr.bin/cvs/lib/getwd.c b/gnu/usr.bin/cvs/lib/getwd.c deleted file mode 100644 index 573a7889244..00000000000 --- a/gnu/usr.bin/cvs/lib/getwd.c +++ /dev/null @@ -1,35 +0,0 @@ -/* getwd.c -- get current working directory pathname - Copyright (C) 1992 Free Software Foundation, Inc. - - This program 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, or (at your option) - any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Some systems which include both getwd() and getcwd() have an implementation - of getwd() which is much faster than getcwd(). As a result, we use the - system's getwd() if it is available */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "system.h" - -/* Get the current working directory into PATHNAME */ - -char * -getwd (pathname) - char *pathname; -{ - return (getcwd(pathname, PATH_MAX)); -} diff --git a/gnu/usr.bin/cvs/lib/strdup.c b/gnu/usr.bin/cvs/lib/strdup.c deleted file mode 100644 index 46fc8a0d6db..00000000000 --- a/gnu/usr.bin/cvs/lib/strdup.c +++ /dev/null @@ -1,43 +0,0 @@ -/* strdup.c -- return a newly allocated copy of a string - Copyright (C) 1990 Free Software Foundation, Inc. - - This program 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, or (at your option) - any later version. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#ifdef STDC_HEADERS -#include <string.h> -#include <stdlib.h> -#else -char *malloc (); -char *strcpy (); -#endif - -/* Return a newly allocated copy of STR, - or 0 if out of memory. */ - -char * -strdup (str) - char *str; -{ - char *newstr; - - newstr = (char *) malloc (strlen (str) + 1); - if (newstr) - strcpy (newstr, str); - return newstr; -} |