Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!samsung!munnari.oz.au!basser!ultima!nick From: nick@ultima.cs.uts.oz (Nick Andrew) Newsgroups: comp.os.minix Subject: News for Minix (part 13, 2 missing files) Keywords: news Message-ID: <16802@ultima.cs.uts.oz> Date: 21 Dec 89 12:24:20 GMT Organization: Comp Sci, NSWIT, Australia Lines: 961 It was just pointed out to me (and most politely, if I do say so) that I missed posting one file in my recent News 2.11 posting. This file was ndir.h ... somehow I posted ndir.c twice. Additionally, for those without a Yacc, I have converted getdate.y into getdate.c using BSD Yacc and included that in this posting. There seems to have been a resounding lack of response from the newsgroup about these News postings. Is it just the Xmas cheer (and holidays), or are the postings not getting out? M E R R Y C H R I S T M A S T O A L L . . . Nick. #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh 'ndir.h' <<'END_OF_FILE' X/* @(#)ndir.h 1.6 3/9/87 */ X#if defined(HP9K5) X/* He should have included it instead of this, but prevent confusion */ X#include X#else /* other */ X#ifndef DEV_BSIZE X#define DEV_BSIZE 512 X#endif X#define DIRBLKSIZ DEV_BSIZE X#define MAXNAMLEN 255 X Xstruct direct { X long d_ino; /* inode number of entry */ X short d_reclen; /* length of this record */ X short d_namlen; /* length of string in d_name */ X char d_name[MAXNAMLEN + 1]; /* name must be no longer than this */ X}; X X/* X * The DIRSIZ macro gives the minimum record length which will hold X * the directory entry. This requires the amount of space in struct direct X * without the d_name field, plus enough space for the name with a terminating X * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary. X */ X X#ifdef DIRSIZ X#undef DIRSIZ X#endif /* DIRSIZ */ X#define DIRSIZ(dp) \ X ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3)) X X/* X * Definitions for library routines operating on directories. X */ Xtypedef struct _dirdesc { X int dd_fd; X long dd_loc; X long dd_size; X char dd_buf[DIRBLKSIZ]; X} DIR; X#ifndef NULL X#define NULL 0 X#endif Xextern DIR *opendir(); Xextern struct direct *readdir(); Xextern void closedir(); X X#define rewinddir(dirp) seekdir((dirp), (long)0) X#endif /* other */ END_OF_FILE if test 1281 -ne `wc -c <'ndir.h'`; then echo shar: \"'ndir.h'\" unpacked with wrong size! fi # end of 'ndir.h' fi if test -f 'getdate.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'getdate.c'\" else echo shar: Extracting \"'getdate.c'\" \(19766 characters\) sed "s/^X//" >'getdate.c' <<'END_OF_FILE' X# define ID 257 X# define MONTH 258 X# define DAY 259 X# define MERIDIAN 260 X# define NUMBER 261 X# define UNIT 262 X# define MUNIT 263 X# define SUNIT 264 X# define ZONE 265 X# define DAYZONE 266 X# define AGO 267 X X# line 3 "getdate.y" X /* Originally from: Steven M. Bellovin (unc!smb) */ X /* Dept. of Computer Science */ X /* University of North Carolina at Chapel Hill */ X /* @(#)getdate.y 2.15 12/16/86 */ X X#include X#ifdef USG Xstruct timeb X{ X time_t time; X unsigned short millitm; X short timezone; X short dstflag; X}; X#else X#include X#endif X#include X X#include "defs.h" X#if defined(BSD4_2) || defined (BSD4_1C) X#include X#else /* sane */ X#include X#endif /* sane */ X X#define NULL 0 X#define daysec (24L*60L*60L) X static int timeflag, zoneflag, dateflag, dayflag, relflag; X static time_t relsec, relmonth; X static int hh, mm, ss, merid, daylight; X static int dayord, dayreq; X static int month, day, year; X static int ourzone; X#define AM 1 X#define PM 2 X#define DAYLIGHT 1 X#define STANDARD 2 X#define MAYBE 3 X#define yyclearin yychar = -1 X#define yyerrok yyerrflag = 0 Xextern int yychar; Xextern short yyerrflag; X#ifndef YYMAXDEPTH X#define YYMAXDEPTH 150 X#endif X#ifndef YYSTYPE X#define YYSTYPE int X#endif XYYSTYPE yylval, yyval; X# define YYERRCODE 256 X X# line 121 "getdate.y" X X Xstatic int mdays[12] = X {31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; X#define epoch 1970 X Xextern struct tm *localtime(); X Xtime_t Xdateconv(mm, dd, yy, h, m, s, mer, zone, dayflag) Xint mm, dd, yy, h, m, s, mer, zone, dayflag; X{ X time_t tod, jdate; X register int i; X time_t timeconv(); X X if (yy < 0) yy = -yy; X if (yy < 100) yy += 1900; X mdays[1] = 28 + (yy%4 == 0 && (yy%100 != 0 || yy%400 == 0)); X if (yy < epoch || yy > 1999 || mm < 1 || mm > 12 || X dd < 1 || dd > mdays[--mm]) return (-1); X jdate = dd-1; X for (i=0; itm_isdst)) X jdate += -1*60*60; X return (jdate); X} X Xtime_t Xdayconv(ord, day, now) Xint ord, day; time_t now; X{ X register struct tm *loctime; X time_t tod; X time_t daylcorr(); X X tod = now; X loctime = localtime(&tod); X tod += daysec * ((day - loctime->tm_wday + 7) % 7); X tod += 7*daysec*(ord<=0?ord:ord-1); X return daylcorr(tod, now); X} X Xtime_t Xtimeconv(hh, mm, ss, mer) Xregister int hh, mm, ss, mer; X{ X if (mm < 0 || mm > 59 || ss < 0 || ss > 59) return (-1); X switch (mer) { X case AM: if (hh < 1 || hh > 12) return(-1); X return (60L * ((hh%12)*60L + mm)+ss); X case PM: if (hh < 1 || hh > 12) return(-1); X return (60L * ((hh%12 +12)*60L + mm)+ss); X case 24: if (hh < 0 || hh > 23) return (-1); X return (60L * (hh*60L + mm)+ss); X default: return (-1); X } X} Xtime_t Xmonthadd(sdate, relmonth) Xtime_t sdate, relmonth; X{ X struct tm *ltime; X time_t dateconv(); X time_t daylcorr(); X int mm, yy; X X if (relmonth == 0) return 0; X ltime = localtime(&sdate); X mm = 12*ltime->tm_year + ltime->tm_mon + relmonth; X yy = mm/12; X mm = mm%12 + 1; X return daylcorr(dateconv(mm, ltime->tm_mday, yy, ltime->tm_hour, X ltime->tm_min, ltime->tm_sec, 24, ourzone, MAYBE), sdate); X} X Xtime_t Xdaylcorr(future, now) Xtime_t future, now; X{ X int fdayl, nowdayl; X X nowdayl = (localtime(&now)->tm_hour+1) % 24; X fdayl = (localtime(&future)->tm_hour+1) % 24; X return (future-now) + 60L*60L*(nowdayl-fdayl); X} X Xstatic char *lptr; X Xyylex() X{ X extern int yylval; X int sign; X register char c; X register char *p; X char idbuf[20]; X int pcnt; X X for (;;) { X while (isspace(*lptr)) X lptr++; X X if (isdigit(c = *lptr) || c == '-' || c == '+') { X if (c== '-' || c == '+') { X if (c=='-') sign = -1; X else sign = 1; X if (!isdigit(*++lptr)) { X /* yylval = sign; return (NUMBER); */ X return yylex(); /* skip the '-' sign */ X } X } else sign = 1; X yylval = 0; X while (isdigit(c = *lptr++)) X yylval = 10*yylval + c - '0'; X yylval *= sign; X lptr--; X return (NUMBER); X X } else if (isalpha(c)) { X p = idbuf; X while (isalpha(c = *lptr++) || c=='.') X *p++ = c; X *p = '\0'; X lptr--; X return (lookup(idbuf)); X } X X else if (c == '(') { X pcnt = 0; X do { X c = *lptr++; X if (c == '\0') return(c); X else if (c == '(') pcnt++; X else if (c == ')') pcnt--; X } while (pcnt > 0); X } X X else return (*lptr++); X } X} X Xstruct table { X char *name; X int type, value; X}; X Xstruct table mdtab[] = { X {"january", MONTH, 1}, X {"february", MONTH, 2}, X {"march", MONTH, 3}, X {"april", MONTH, 4}, X {"may", MONTH, 5}, X {"june", MONTH, 6}, X {"july", MONTH, 7}, X {"august", MONTH, 8}, X {"september", MONTH, 9}, X {"sept", MONTH, 9}, X {"october", MONTH, 10}, X {"november", MONTH, 11}, X {"december", MONTH, 12}, X X {"sunday", DAY, 0}, X {"monday", DAY, 1}, X {"tuesday", DAY, 2}, X {"tues", DAY, 2}, X {"wednesday", DAY, 3}, X {"wednes", DAY, 3}, X {"thursday", DAY, 4}, X {"thur", DAY, 4}, X {"thurs", DAY, 4}, X {"friday", DAY, 5}, X {"saturday", DAY, 6}, X {0, 0, 0}}; X X#define HRS *60 X#define HALFHR 30 Xstruct table mztab[] = { X {"a.m.", MERIDIAN, AM}, X {"am", MERIDIAN, AM}, X {"p.m.", MERIDIAN, PM}, X {"pm", MERIDIAN, PM}, X {"nst", ZONE, 3 HRS + HALFHR}, /* Newfoundland */ X {"n.s.t.", ZONE, 3 HRS + HALFHR}, X {"ast", ZONE, 4 HRS}, /* Atlantic */ X {"a.s.t.", ZONE, 4 HRS}, X {"adt", DAYZONE, 4 HRS}, X {"a.d.t.", DAYZONE, 4 HRS}, X {"est", ZONE, 5 HRS}, /* Eastern */ X {"e.s.t.", ZONE, 5 HRS}, X {"edt", DAYZONE, 5 HRS}, X {"e.d.t.", DAYZONE, 5 HRS}, X {"cst", ZONE, 6 HRS}, /* Central */ X {"c.s.t.", ZONE, 6 HRS}, X {"cdt", DAYZONE, 6 HRS}, X {"c.d.t.", DAYZONE, 6 HRS}, X {"mst", ZONE, 7 HRS}, /* Mountain */ X {"m.s.t.", ZONE, 7 HRS}, X {"mdt", DAYZONE, 7 HRS}, X {"m.d.t.", DAYZONE, 7 HRS}, X {"pst", ZONE, 8 HRS}, /* Pacific */ X {"p.s.t.", ZONE, 8 HRS}, X {"pdt", DAYZONE, 8 HRS}, X {"p.d.t.", DAYZONE, 8 HRS}, X {"yst", ZONE, 9 HRS}, /* Yukon */ X {"y.s.t.", ZONE, 9 HRS}, X {"ydt", DAYZONE, 9 HRS}, X {"y.d.t.", DAYZONE, 9 HRS}, X {"hst", ZONE, 10 HRS}, /* Hawaii */ X {"h.s.t.", ZONE, 10 HRS}, X {"hdt", DAYZONE, 10 HRS}, X {"h.d.t.", DAYZONE, 10 HRS}, X X {"gmt", ZONE, 0 HRS}, X {"g.m.t.", ZONE, 0 HRS}, X {"bst", DAYZONE, 0 HRS}, /* British Summer Time */ X {"b.s.t.", DAYZONE, 0 HRS}, X {"eet", ZONE, 0 HRS}, /* European Eastern Time */ X {"e.e.t.", ZONE, 0 HRS}, X {"eest", DAYZONE, 0 HRS}, /* European Eastern Summer Time */ X {"e.e.s.t.", DAYZONE, 0 HRS}, X {"met", ZONE, -1 HRS}, /* Middle European Time */ X {"m.e.t.", ZONE, -1 HRS}, X {"mest", DAYZONE, -1 HRS}, /* Middle European Summer Time */ X {"m.e.s.t.", DAYZONE, -1 HRS}, X {"wet", ZONE, -2 HRS }, /* Western European Time */ X {"w.e.t.", ZONE, -2 HRS }, X {"west", DAYZONE, -2 HRS}, /* Western European Summer Time */ X {"w.e.s.t.", DAYZONE, -2 HRS}, X X {"jst", ZONE, -9 HRS}, /* Japan Standard Time */ X {"j.s.t.", ZONE, -9 HRS}, /* Japan Standard Time */ X /* No daylight savings time */ X X {"aest", ZONE, -10 HRS}, /* Australian Eastern Time */ X {"a.e.s.t.", ZONE, -10 HRS}, X {"aesst", DAYZONE, -10 HRS}, /* Australian Eastern Summer Time */ X {"a.e.s.s.t.", DAYZONE, -10 HRS}, X {"acst", ZONE, -(9 HRS + HALFHR)}, /* Australian Central Time */ X {"a.c.s.t.", ZONE, -(9 HRS + HALFHR)}, X {"acsst", DAYZONE, -(9 HRS + HALFHR)}, /* Australian Central Summer */ X {"a.c.s.s.t.", DAYZONE, -(9 HRS + HALFHR)}, X {"awst", ZONE, -8 HRS}, /* Australian Western Time */ X {"a.w.s.t.", ZONE, -8 HRS}, /* (no daylight time there, I'm told */ X {0, 0, 0}}; X Xstruct table unittb[] = { X {"year", MUNIT, 12}, X {"month", MUNIT, 1}, X {"fortnight", UNIT, 14*24*60}, X {"week", UNIT, 7*24*60}, X {"day", UNIT, 1*24*60}, X {"hour", UNIT, 60}, X {"minute", UNIT, 1}, X {"min", UNIT, 1}, X {"second", SUNIT, 1}, X {"sec", SUNIT, 1}, X {0, 0, 0}}; X Xstruct table othertb[] = { X {"tomorrow", UNIT, 1*24*60}, X {"yesterday", UNIT, -1*24*60}, X {"today", UNIT, 0}, X {"now", UNIT, 0}, X {"last", NUMBER, -1}, X {"this", UNIT, 0}, X {"next", NUMBER, 2}, X {"first", NUMBER, 1}, X /* {"second", NUMBER, 2}, */ X {"third", NUMBER, 3}, X {"fourth", NUMBER, 4}, X {"fifth", NUMBER, 5}, X {"sixth", NUMBER, 6}, X {"seventh", NUMBER, 7}, X {"eigth", NUMBER, 8}, X {"ninth", NUMBER, 9}, X {"tenth", NUMBER, 10}, X {"eleventh", NUMBER, 11}, X {"twelfth", NUMBER, 12}, X {"ago", AGO, 1}, X {0, 0, 0}}; X Xstruct table milzone[] = { X {"a", ZONE, 1 HRS}, X {"b", ZONE, 2 HRS}, X {"c", ZONE, 3 HRS}, X {"d", ZONE, 4 HRS}, X {"e", ZONE, 5 HRS}, X {"f", ZONE, 6 HRS}, X {"g", ZONE, 7 HRS}, X {"h", ZONE, 8 HRS}, X {"i", ZONE, 9 HRS}, X {"k", ZONE, 10 HRS}, X {"l", ZONE, 11 HRS}, X {"m", ZONE, 12 HRS}, X {"n", ZONE, -1 HRS}, X {"o", ZONE, -2 HRS}, X {"p", ZONE, -3 HRS}, X {"q", ZONE, -4 HRS}, X {"r", ZONE, -5 HRS}, X {"s", ZONE, -6 HRS}, X {"t", ZONE, -7 HRS}, X {"u", ZONE, -8 HRS}, X {"v", ZONE, -9 HRS}, X {"w", ZONE, -10 HRS}, X {"x", ZONE, -11 HRS}, X {"y", ZONE, -12 HRS}, X {"z", ZONE, 0 HRS}, X {0, 0, 0}}; X Xlookup(id) Xchar *id; X{ X#define gotit (yylval=i->value, i->type) X X char idvar[128]; X register char *j, *k; X register struct table *i; X int abbrev; X X (void) strcpy(idvar, id); X j = idvar; X k = id - 1; X while (*++k) X *j++ = isupper(*k) ? tolower(*k) : *k; X *j = '\0'; X X if (strlen(idvar) == 3) X abbrev = 1; X else X if (strlen(idvar) == 4 && idvar[3] == '.') { X abbrev = 1; X idvar[3] = '\0'; X } X else X abbrev = 0; X X for (i = mdtab; i->name; i++) { X k = idvar; X for (j = i->name; *j++ == *k++;) { X if (abbrev && j == i->name+3) X return gotit; X if (j[-1] == 0) X return gotit; X } X } X X for (i = mztab; i->name; i++) X if (strcmp(i->name, idvar) == 0) X return gotit; X X for (i=mztab; i->name; i++) X if (strcmp(i->name, idvar) == 0) X return gotit; X X for (i=unittb; i->name; i++) X if (strcmp(i->name, idvar) == 0) X return gotit; X X if (idvar[strlen(idvar)-1] == 's') X idvar[strlen(idvar)-1] = '\0'; X X for (i=unittb; i->name; i++) X if (strcmp(i->name, idvar) == 0) X return gotit; X X for (i = othertb; i->name; i++) X if (strcmp(i->name, idvar) == 0) X return gotit; X X if (strlen(idvar) == 1 && isalpha(*idvar)) { X for (i = milzone; i->name; i++) X if (strcmp(i->name, idvar) == 0) X return gotit; X } X X return ID; X} X Xtime_t Xgetdate(p, now) Xchar *p; Xstruct timeb *now; X{ X#define mcheck(f) if (f>1) err++ X time_t monthadd(); X int err; X struct tm *lt; X struct timeb ftz; X X time_t sdate, tod; X X lptr = p; X if (now == ((struct timeb *) NULL)) { X now = &ftz; X ftime(&ftz); X } X lt = localtime(&now->time); X year = lt->tm_year; X month = lt->tm_mon+1; X day = lt->tm_mday; X relsec = 0; relmonth = 0; X timeflag=zoneflag=dateflag=dayflag=relflag=0; X ourzone = now->timezone; X daylight = MAYBE; X hh = mm = ss = 0; X merid = 24; X X if (err = yyparse()) return (-1); X X mcheck(timeflag); X mcheck(zoneflag); X mcheck(dateflag); X mcheck(dayflag); X X if (err) return (-1); X if (dateflag || timeflag || dayflag) { X sdate = dateconv(month,day,year,hh,mm,ss,merid,ourzone,daylight); X if (sdate < 0) return -1; X } X else { X sdate = now->time; X if (relflag == 0) X sdate -= (lt->tm_sec + lt->tm_min*60 + X lt->tm_hour*(60L*60L)); X } X X sdate += relsec; X sdate += monthadd(sdate, relmonth); X X if (dayflag && !dateflag) { X tod = dayconv(dayord, dayreq, sdate); X sdate += tod; X } X X return sdate; X} X Xyyerror(s) char *s; X{} Xshort yyexca[] ={ X-1, 1, X 0, -1, X -2, 0, X }; X# define YYNPROD 35 X# define YYLAST 220 Xshort yyact[]={ X X 12, 13, 21, 9, 14, 15, 16, 10, 11, 34, X 17, 39, 40, 19, 38, 37, 36, 30, 29, 28, X 26, 35, 31, 27, 8, 7, 6, 5, 4, 3, X 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, X 0, 32, 33, 22, 20, 18, 0, 23, 24, 25 }; Xshort yypact[]={ X X-1000,-258,-1000,-1000,-1000,-1000,-1000,-257,-1000, -45, X-1000,-1000,-241, -21,-1000,-1000,-1000,-1000,-1000,-242, X-1000,-243,-244,-1000,-1000,-1000, -22,-1000, -49, -26, X-1000,-245,-1000,-1000,-246,-247,-1000,-249,-1000,-1000, X-1000 }; Xshort yypgo[]={ X X 0, 31, 30, 29, 28, 27, 26, 25, 24 }; Xshort yyr1[]={ X X 0, 1, 1, 2, 2, 2, 2, 2, 2, 8, X 3, 3, 3, 3, 3, 3, 3, 4, 4, 6, X 6, 6, 5, 5, 5, 5, 5, 5, 7, 7, X 7, 7, 7, 7, 7 }; Xshort yyr2[]={ X X 0, 0, 2, 1, 1, 1, 1, 1, 1, 1, X 2, 3, 4, 4, 5, 6, 6, 1, 1, 1, X 2, 2, 3, 5, 2, 4, 2, 3, 2, 2, X 2, 1, 1, 1, 2 }; Xshort yychk[]={ X X-1000, -1, -2, -3, -4, -5, -6, -7, -8, 261, X 265, 266, 258, 259, 262, 263, 264, 267, 260, 58, X 259, 47, 258, 262, 263, 264, 261, 44, 261, 261, X 261, 44, 260, 261, 58, 47, 261, 261, 261, 260, X 261 }; Xshort yydef[]={ X X 1, -2, 2, 3, 4, 5, 6, 7, 8, 9, X 17, 18, 0, 19, 31, 32, 33, 34, 10, 0, X 21, 0, 26, 28, 29, 30, 24, 20, 11, 22, X 27, 0, 12, 13, 0, 0, 25, 14, 23, 15, X 16 }; X#ifndef lint Xstatic char yaccpar_sccsid[] = "@(#)yaccpar 1.6 88/02/08 SMI"; /* from UCB 4.1 83/02/11 */ X#endif X X# X# define YYFLAG -1000 X# define YYERROR goto yyerrlab X# define YYACCEPT return(0) X# define YYABORT return(1) X X/* parser for yacc output */ X X#ifdef YYDEBUG Xint yydebug = 0; /* 1 for debugging */ X#endif XYYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */ Xint yychar = -1; /* current input token number */ Xint yynerrs = 0; /* number of errors */ Xshort yyerrflag = 0; /* error recovery flag */ X Xyyparse() { X X short yys[YYMAXDEPTH]; X short yyj, yym; X register YYSTYPE *yypvt; X register short yystate, *yyps, yyn; X register YYSTYPE *yypv; X register short *yyxi; X X yystate = 0; X yychar = -1; X yynerrs = 0; X yyerrflag = 0; X yyps= &yys[-1]; X yypv= &yyv[-1]; X X yystack: /* put a state and value onto the stack */ X X#ifdef YYDEBUG X if( yydebug ) printf( "state %d, char 0%o\n", yystate, yychar ); X#endif X if( ++yyps>= &yys[YYMAXDEPTH] ) { yyerror( "yacc stack overflow" ); return(1); } X *yyps = yystate; X ++yypv; X *yypv = yyval; X X yynewstate: X X yyn = yypact[yystate]; X X if( yyn<= YYFLAG ) goto yydefault; /* simple state */ X X if( yychar<0 ) if( (yychar=yylex())<0 ) yychar=0; X if( (yyn += yychar)<0 || yyn >= YYLAST ) goto yydefault; X X if( yychk[ yyn=yyact[ yyn ] ] == yychar ){ /* valid shift */ X yychar = -1; X yyval = yylval; X yystate = yyn; X if( yyerrflag > 0 ) --yyerrflag; X goto yystack; X } X X yydefault: X /* default state action */ X X if( (yyn=yydef[yystate]) == -2 ) { X if( yychar<0 ) if( (yychar=yylex())<0 ) yychar = 0; X /* look through exception table */ X X for( yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate) ; yyxi += 2 ) ; /* VOID */ X X while( *(yyxi+=2) >= 0 ){ X if( *yyxi == yychar ) break; X } X if( (yyn = yyxi[1]) < 0 ) return(0); /* accept */ X } X X if( yyn == 0 ){ /* error */ X /* error ... attempt to resume parsing */ X X switch( yyerrflag ){ X X case 0: /* brand new error */ X X yyerror( "syntax error" ); X yyerrlab: X ++yynerrs; X X case 1: X case 2: /* incompletely recovered error ... try again */ X X yyerrflag = 3; X X /* find a state where "error" is a legal shift action */ X X while ( yyps >= yys ) { X yyn = yypact[*yyps] + YYERRCODE; X if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){ X yystate = yyact[yyn]; /* simulate a shift of "error" */ X goto yystack; X } X yyn = yypact[*yyps]; X X /* the current yyps has no shift onn "error", pop stack */ X X#ifdef YYDEBUG X if( yydebug ) printf( "error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] ); X#endif X --yyps; X --yypv; X } X X /* there is no state on the stack with an error shift ... abort */ X X yyabort: X return(1); X X X case 3: /* no shift yet; clobber input char */ X X#ifdef YYDEBUG X if( yydebug ) printf( "error recovery discards char %d\n", yychar ); X#endif X X if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */ X yychar = -1; X goto yynewstate; /* try again in the same state */ X X } X X } X X /* reduction by production yyn */ X X#ifdef YYDEBUG X if( yydebug ) printf("reduce %d\n",yyn); X#endif X yyps -= yyr2[yyn]; X yypvt = yypv; X yypv -= yyr2[yyn]; X yyval = yypv[1]; X yym=yyn; X /* consult goto table to find next state */ X yyn = yyr1[yyn]; X yyj = yypgo[yyn] + *yyps + 1; X if( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]]; X switch(yym){ X Xcase 3: X# line 48 "getdate.y" X X {timeflag++;} break; Xcase 4: X# line 50 "getdate.y" X X {zoneflag++;} break; Xcase 5: X# line 52 "getdate.y" X X {dateflag++;} break; Xcase 6: X# line 54 "getdate.y" X X {dayflag++;} break; Xcase 7: X# line 56 "getdate.y" X X {relflag++;} break; Xcase 9: X# line 60 "getdate.y" X X {if (timeflag && dateflag && !relflag) year = yypvt[-0]; X else {timeflag++;hh = yypvt[-0]/100;mm = yypvt[-0]%100;ss = 0;merid = 24;}} break; Xcase 10: X# line 64 "getdate.y" X X {hh = yypvt[-1]; mm = 0; ss = 0; merid = yypvt[-0];} break; Xcase 11: X# line 66 "getdate.y" X X {hh = yypvt[-2]; mm = yypvt[-0]; merid = 24;} break; Xcase 12: X# line 68 "getdate.y" X X {hh = yypvt[-3]; mm = yypvt[-1]; merid = yypvt[-0];} break; Xcase 13: X# line 70 "getdate.y" X X {hh = yypvt[-3]; mm = yypvt[-1]; merid = 24; X daylight = STANDARD; ourzone = -(yypvt[-0]%100 + 60*(yypvt[-0]/100));} break; Xcase 14: X# line 73 "getdate.y" X X {hh = yypvt[-4]; mm = yypvt[-2]; ss = yypvt[-0]; merid = 24;} break; Xcase 15: X# line 75 "getdate.y" X X {hh = yypvt[-5]; mm = yypvt[-3]; ss = yypvt[-1]; merid = yypvt[-0];} break; Xcase 16: X# line 77 "getdate.y" X X {hh = yypvt[-5]; mm = yypvt[-3]; ss = yypvt[-1]; merid = 24; X daylight = STANDARD; ourzone = -(yypvt[-0]%100 + 60*(yypvt[-0]/100));} break; Xcase 17: X# line 81 "getdate.y" X X {ourzone = yypvt[-0]; daylight = STANDARD;} break; Xcase 18: X# line 83 "getdate.y" X X {ourzone = yypvt[-0]; daylight = DAYLIGHT;} break; Xcase 19: X# line 86 "getdate.y" X X {dayord = 1; dayreq = yypvt[-0];} break; Xcase 20: X# line 88 "getdate.y" X X {dayord = 1; dayreq = yypvt[-1];} break; Xcase 21: X# line 90 "getdate.y" X X {dayord = yypvt[-1]; dayreq = yypvt[-0];} break; Xcase 22: X# line 93 "getdate.y" X X {month = yypvt[-2]; day = yypvt[-0];} break; Xcase 23: X# line 95 "getdate.y" X X {month = yypvt[-4]; day = yypvt[-2]; year = yypvt[-0];} break; Xcase 24: X# line 97 "getdate.y" X X {month = yypvt[-1]; day = yypvt[-0];} break; Xcase 25: X# line 99 "getdate.y" X X {month = yypvt[-3]; day = yypvt[-2]; year = yypvt[-0];} break; Xcase 26: X# line 101 "getdate.y" X X {month = yypvt[-0]; day = yypvt[-1];} break; Xcase 27: X# line 103 "getdate.y" X X {month = yypvt[-1]; day = yypvt[-2]; year = yypvt[-0];} break; Xcase 28: X# line 107 "getdate.y" X X {relsec += 60L * yypvt[-1] * yypvt[-0];} break; Xcase 29: X# line 109 "getdate.y" X X {relmonth += yypvt[-1] * yypvt[-0];} break; Xcase 30: X# line 111 "getdate.y" X X {relsec += yypvt[-1];} break; Xcase 31: X# line 113 "getdate.y" X X {relsec += 60L * yypvt[-0];} break; Xcase 32: X# line 115 "getdate.y" X X {relmonth += yypvt[-0];} break; Xcase 33: X# line 117 "getdate.y" X X {relsec++;} break; Xcase 34: X# line 119 "getdate.y" X X {relsec = -relsec; relmonth = -relmonth;} break; X } X goto yystack; /* stack new state and value */ X X } END_OF_FILE if test 19766 -ne `wc -c <'getdate.c'`; then echo shar: \"'getdate.c'\" unpacked with wrong size! fi # end of 'getdate.c' fi echo shar: End of shell archive. exit 0 -- "Zeta Microcomputer Software" ACSnet: nick@ultima.cs.uts.oz UUCP: ...!uunet!munnari!ultima.cs.uts.oz!nick Fidonet: Nick Andrew on 3:713/602 (Zeta)