--- Makefile.in +++ Makefile.in 2000/11/28 00:21:30 @@ -14,8 +14,6 @@ man1dir = $(mandir)/man1 man5dir = $(mandir)/man5 man8dir = $(mandir)/man8 -docdir = $(prefix)/doc -atdocdir = $(docdir)/at etcdir = @ETCDIR@ DAEMON_USERNAME = @DAEMON_USERNAME@ @@ -87,38 +85,25 @@ $(CC) -c $(CFLAGS) $(DEFS) $*.c install: all - $(INSTALL) -g root -o root -m 755 -d $(IROOT)$(etcdir) - $(INSTALL) -g root -o root -m 755 -d $(IROOT)$(bindir) - $(INSTALL) -g root -o root -m 755 -d $(IROOT)$(sbindir) - $(INSTALL) -g root -o root -m 755 -d $(IROOT)$(docdir) - $(INSTALL) -g root -o root -m 755 -d $(IROOT)$(atdocdir) - $(INSTALL) -m 755 -d $(IROOT)$(ATJOB_DIR) - $(INSTALL) -g $(DAEMON_GROUPNAME) -o $(DAEMON_USERNAME) -m 755 -d $(IROOT)$(ATSPOOL_DIR) + mkdir -p $(IROOT)$(ATJOB_DIR) $(IROOT)$(ATSPOOL_DIR) chmod 700 $(IROOT)$(ATJOB_DIR) $(IROOT)$(ATSPOOL_DIR) chown $(DAEMON_USERNAME):$(DAEMON_GROUPNAME) $(IROOT)$(ATJOB_DIR) $(IROOT)$(ATSPOOL_DIR) touch $(IROOT)$(LFILE) chmod 600 $(IROOT)$(LFILE) chown $(DAEMON_USERNAME):$(DAEMON_GROUPNAME) $(IROOT)$(LFILE) - test -f $(IROOT)$(etcdir)/at.allow || test -f $(IROOT)$(etcdir)/at.deny || $(INSTALL) -o root -m 600 at.deny $(IROOT)$(etcdir)/ - $(INSTALL) -g root -o root -m 4755 -s at $(IROOT)$(bindir) + $(INSTALL) -m 600 at.deny $(IROOT)$(etcdir)/ + $(INSTALL) -m 4755 -s at $(IROOT)$(bindir) $(LN_S) -f at $(IROOT)$(bindir)/atq $(LN_S) -f at $(IROOT)$(bindir)/atrm - $(INSTALL) -g root -o root -m 755 batch $(IROOT)$(bindir) - $(INSTALL) -d -o root -g root -m 755 $(IROOT)$(man1dir) - $(INSTALL) -d -o root -g root -m 755 $(IROOT)$(man5dir) - $(INSTALL) -d -o root -g root -m 755 $(IROOT)$(man8dir) - $(INSTALL) -g root -o root -m 755 -s atd $(IROOT)$(sbindir) - $(INSTALL) -g root -o root -m 755 atrun $(IROOT)$(sbindir) - $(INSTALL) -g root -o root -m 644 at.1 $(IROOT)$(man1dir)/ + $(INSTALL) -s batch $(IROOT)$(bindir) + $(INSTALL) -s atd $(IROOT)$(sbindir) + $(INSTALL) -s atrun $(IROOT)$(sbindir) + $(INSTALL) -m 644 at.1 $(IROOT)$(man1dir)/ cd $(IROOT)$(man1dir) && $(LN_S) -f at.1 atq.1 && $(LN_S) -f at.1 batch.1 && $(LN_S) -f at.1 atrm.1 $(INSTALL) -g root -o root -m 644 atd.8 $(IROOT)$(man8dir)/ $(INSTALL) -g root -o root -m 644 atrun.8 $(IROOT)$(man8dir)/ $(INSTALL) -g root -o root -m 644 at_allow.5 $(IROOT)$(man5dir)/ cd $(IROOT)$(man5dir) && $(LN_S) -f at_allow.5 at_deny.5 - $(INSTALL) -g root -o root -m 644 $(DOCS) $(IROOT)$(atdocdir) - rm -f $(IROOT)$(mandir)/cat1/at.1* $(IROOT)$(mandir)/cat1/batch.1* \ - $(IROOT)$(mandir)/cat1/atq.1* - rm -f $(IROOT)$(mandir)/cat1/atd.8* dist: checkin $(DIST) $(LIST) Filelist.asc (cd ..; tar cf - `for a in $(DIST) $(LIST); do echo at-$(VERSION)/$$a; done` |\ --- Problems +++ Problems 2000/11/28 00:21:30 @@ -5,7 +5,7 @@ make -f Makefile.old install -- You may not have a user or group 'daemon' on your system. +- You may not have a user or group 'at' on your system. - If you find numerous 'try again' error messages in your syslog files, you have too many processes running; recompile your kernel for a --- README +++ README 2000/11/28 00:21:30 @@ -23,7 +23,7 @@ The old one is to put -* * * * 0,5,10,15,20,25,30,35,40,45,50,55 /usr/lib/atrun +* * * * 0,5,10,15,20,25,30,35,40,45,50,55 /usr/sbin/atrun into root's crontab file (or wherever you put the atrun binary; don't forget to start up cron.) --- at.1.in +++ at.1.in 2000/11/28 00:21:30 @@ -248,7 +248,11 @@ .br .I @ETCDIR@/at.deny .SH SEE ALSO -cron(1), nice(1), sh(1), umask(2), atd(8) +.BR cron (1), +.BR nice (1), +.BR sh (1), +.BR umask (2), +.BR atd (8). .SH BUGS The correct operation of .B batch --- at.c +++ at.c 2000/11/28 00:21:30 @@ -235,6 +235,7 @@ /* Install the signal handler for SIGINT; terminate after removing the * spool file if necessary */ + memset(&act, 0, sizeof act); act.sa_handler = sigc; sigemptyset(&(act.sa_mask)); act.sa_flags = 0; @@ -274,8 +275,8 @@ if ((jobno = nextjob()) == EOF) perr("Cannot generate job number"); - sprintf(ppos, "%c%5lx%8lx", queue, - jobno, (unsigned long) (runtimer / 60)); + (void)snprintf(ppos, sizeof(atfile) - (ppos - atfile), + "%c%5lx%8lx", queue, jobno, (unsigned long) (runtimer / 60)); for (ap = ppos; *ap != '\0'; ap++) if (*ap == ' ') @@ -291,7 +292,7 @@ * bit. Yes, this is a kluge. */ cmask = umask(S_IRUSR | S_IWUSR | S_IXUSR); - if ((fd = creat(atfile, O_WRONLY)) == -1) + if ((fd = open(atfile, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR)) == -1) perr("Cannot create atjob file %.500s", atfile); if ((fd2 = dup(fd)) < 0) @@ -461,14 +462,6 @@ close(fd2); - /* POSIX.2 allows the shell specified by the user's SHELL environment - variable, the login shell from the user's password database entry, - or /bin/sh to be the command interpreter that processes the at-job. - It also alows a warning diagnostic to be printed. Because of the - possible variance, we always output the diagnostic. */ - - fprintf(stderr, "warning: commands will be executed using /bin/sh\n"); - runtime = localtime(&runtimer); /* We only use the sick POSIX time format if POSIXLY_CORRECT @@ -546,6 +539,7 @@ long jobno; time_t runtimer; char timestr[TIMESIZE]; + struct passwd *pwd; PRIV_START @@ -581,7 +575,10 @@ } else { strftime(timestr, TIMESIZE, TIMEFORMAT_ISO, runtime); } - printf("%ld\t%s %c\n", jobno, timestr, queue); + if ((pwd = getpwuid(buf.st_uid))) + printf("%ld\t%s %c %s\n", jobno, timestr, queue, pwd->pw_name); + else + printf("%ld\t%s %c\n", jobno, timestr, queue); } PRIV_END } @@ -695,7 +692,7 @@ char *pgm; int program = AT; /* our default program */ - char *options = "q:f:mvldVc"; /* default options for at */ + char *options = "q:f:MmvldhVc"; /* default options for at */ int disp_version = 0; time_t timer; struct passwd *pwe; @@ -726,16 +723,20 @@ */ if (strcmp(pgm, "atq") == 0) { program = ATQ; - options = "q:V"; + options = "hq:V"; } else if (strcmp(pgm, "atrm") == 0) { program = ATRM; - options = "V"; + options = "hV"; } /* process whatever options we can process */ opterr = 1; while ((c = getopt(argc, argv, options)) != EOF) switch (c) { + case 'h': + usage(); + exit (0); + case 'v': /* verify time settings */ atverify = 1; break; @@ -744,6 +745,10 @@ send_mail = 1; break; + case 'M': /* don't send mail, even when job failed */ + send_mail = -1; + break; + case 'f': atinput = optarg; break; @@ -753,7 +758,7 @@ usage(); atqueue = queue = *optarg; - if (!(islower(queue) || isupper(queue))) + if (!(islower(queue) || isupper(queue)) & (queue != '=')) usage(); queue_set = 1; @@ -842,6 +847,15 @@ struct tm *tm = localtime(&timer); fprintf(stderr, "%s\n", asctime(tm)); } + + /* POSIX.2 allows the shell specified by the user's SHELL environment + variable, the login shell from the user's password database entry, + or /bin/sh to be the command interpreter that processes the at-job. + It also alows a warning diagnostic to be printed. Because of the + possible variance, we always output the diagnostic. */ + + fprintf(stderr, "warning: commands will be executed using /bin/sh\n"); + writefile(timer, queue); break; --- at.deny +++ at.deny 2000/11/28 00:21:30 @@ -1,13 +1,24 @@ -nobody +alias +backup bin daemon -sys +ftp +games +gnats +guest +irc lp -sync mail -news -uucp -games man -guest -ftp +nobody +operator +proxy +qmaild +qmaill +qmailp +qmailq +qmailr +qmails +sync +sys +www-data --- at_allow.5 +++ at_allow.5 2000/11/28 00:21:30 @@ -1,16 +1,16 @@ -.Id $Id: at_allow.5,v 1.1 1997/09/28 20:00:28 ig25 Exp $ -.TH AT_ACCESS 5 "Sep 1997" "" "Linux Programmer's Manual" +.Id $Id: at.allow.5,v 1.1 1997/09/28 20:00:28 ig25 Exp $ +.TH AT.ALLOW 5 "Sep 1997" "" "Linux Programmer's Manual" .SH NAME -at.acess, at.deny \- determine who can submit jobs via at or batch +at.allow, at.deny \- determine who can submit jobs via at or batch .SH DESCRIPTION The -.I /etc/at.access +.I /etc/at.allow and .I /etc/at.deny files determine which user can submit commands for later execution via -.B at(1) +.BR at (1) or -.BR batch(1) . +.BR batch (1) . .PP The format of the files is a list of usernames, one on each line. Whitespace is not permitted. @@ -29,4 +29,8 @@ .I /etc/at.deny is checked. .SH "SEE ALSO" -at(1), atrun(1), cron(1), crontab(1), atd(8) +.BR at (1), +.BR atrun (1), +.BR cron (8), +.BR crontab (1), +.BR atd (8). --- atd.8.in +++ atd.8.in 2000/11/28 00:21:30 @@ -46,6 +46,11 @@ is installed as .B @prefix@/sbin/atrun for backward compatibility. +.SH WARNING +.B atd +won't work if its spool directory is mounted via NFS even if +.I no_root_squash +is set. .SH FILES .I @ATJBD@ The directory for storing jobs; this should be mode 700, owner @@ -61,9 +66,15 @@ .B at system. .SH "SEE ALSO" -at(1), atrun(1), cron(1), crontab(1), syslog(3), at_deny(5), at_allow(5) +.BR at (1), +.BR atrun (1), +.BR cron (8), +.BR crontab (1), +.BR syslog (3), +.BR at.deny (5), +.BR at.allow(5). .SH BUGS The functionality of .B atd should be merged into -.BR cron(1) . +.BR cron (8) . --- atd.c +++ atd.c 2000/11/28 00:21:30 @@ -159,7 +159,7 @@ */ pid_t pid; int fd_out, fd_in; - char mailbuf[9], jobbuf[9]; + char mailbuf[17], jobbuf[9]; char *mailname = NULL; char *newname; FILE *stream; @@ -253,9 +253,14 @@ if ((fflags = fcntl(fd_in, F_GETFD)) < 0) perr("Error in fcntl"); - fcntl(fd_in, F_SETFD, fflags & ~FD_CLOEXEC); + /* + ** fcntl(fd_in, F_SETFD, fflags & ~FD_CLOEXEC); + ** What's that? This fcntl() removes the CLOSE_ON_EXEC flag. + */ + if(fcntl(fd_in, F_SETFD, fflags | FD_CLOEXEC) < 0) + perr("Error in fcntl"); - if (fscanf(stream, "#!/bin/sh\n# atrun uid=%d gid=%d\n# mail %8s %d", + if (fscanf(stream, "#!/bin/sh\n# atrun uid=%d gid=%d\n# mail %16s %d", &nuid, &ngid, mailbuf, &send_mail) != 4) pabort("File %.500s is in wrong format - aborting", filename); @@ -489,7 +494,8 @@ /* Something went wrong the last time this was executed. * Let's remove the lockfile and reschedule. */ - strncpy(lock_name, dirent->d_name, sizeof(lock_name)); + strncpy(lock_name, dirent->d_name, sizeof(lock_name)-1); + lock_name[sizeof(lock_name)-1] = 0; lock_name[0] = '='; unlink(lock_name); next_job = now; @@ -514,7 +520,8 @@ */ run_batch++; if (strcmp(batch_name, dirent->d_name) > 0) { - strncpy(batch_name, dirent->d_name, sizeof(batch_name)); + strncpy(batch_name, dirent->d_name, sizeof(batch_name)-1); + batch_name[sizeof(batch_name)-1] = 0; batch_uid = buf.st_uid; batch_gid = buf.st_gid; batch_queue = queue; --- atrun.8.in +++ atrun.8.in 2000/11/28 00:21:30 @@ -17,3 +17,8 @@ .I -s option, and is provided for backward compatibility with older installations. +.SH SEE ALSO +.BR at (1), +.BR atd (8). +.SH AUTHOR +At was mostly written by Thomas Koenig, ig25@rz.uni-karlsruhe.de. --- config.guess +++ config.guess 2000/11/28 00:21:30 @@ -1,6 +1,6 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc. +# Copyright (C) 1992, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc. # # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -51,35 +51,110 @@ # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - alpha:OSF1:V*:*) - # After 1.2, OSF1 uses "V1.3" for uname -r. - echo alpha-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^V//'` - exit 0 ;; alpha:OSF1:*:*) + if test $UNAME_RELEASE = "V4.0"; then + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + fi + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - echo alpha-dec-osf${UNAME_RELEASE} - exit 0 ;; + cat <<EOF >dummy.s + .globl main + .ent main +main: + .frame \$30,0,\$26,0 + .prologue 0 + .long 0x47e03d80 # implver $0 + lda \$2,259 + .long 0x47e20c21 # amask $2,$1 + srl \$1,8,\$2 + sll \$2,2,\$2 + sll \$0,3,\$0 + addl \$1,\$0,\$0 + addl \$2,\$0,\$0 + ret \$31,(\$26),1 + .end main +EOF + ${CC-cc} dummy.s -o dummy 2>/dev/null + if test "$?" = 0 ; then + ./dummy + case "$?" in + 7) + UNAME_MACHINE="alpha" + ;; + 15) + UNAME_MACHINE="alphaev5" + ;; + 14) + UNAME_MACHINE="alphaev56" + ;; + 10) + UNAME_MACHINE="alphapca56" + ;; + 16) + UNAME_MACHINE="alphaev6" + ;; + esac + fi + rm -f dummy.s dummy + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr [[A-Z]] [[a-z]]` + exit 0 ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit 0 ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-cbm-sysv4 + exit 0;; amiga:NetBSD:*:*) echo m68k-cbm-netbsd${UNAME_RELEASE} exit 0 ;; + amiga:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arc64:OpenBSD:*:*) + echo mips64el-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + hkmips:OpenBSD:*:*) + echo mips-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + pmax:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sgi:OpenBSD:*:*) + echo mips-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + wgrisc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit 0;; - Pyramid*:OSx*:*:*) + arm32:NetBSD:*:*) + echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + exit 0 ;; + SR2?01:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit 0;; + Pyramid*:OSx*:*:*|MIS*:OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit 0 ;; - sun4*:SunOS:5.*:*) + NILE:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit 0 ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; i86pc:SunOS:5.*:*) - echo i386-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize @@ -99,24 +174,86 @@ sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit 0 ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit 0 ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit 0 ;; atari*:NetBSD:*:*) echo m68k-atari-netbsd${UNAME_RELEASE} exit 0 ;; + atari*:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; sun3*:NetBSD:*:*) echo m68k-sun-netbsd${UNAME_RELEASE} exit 0 ;; + sun3*:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; mac68k:NetBSD:*:*) echo m68k-apple-netbsd${UNAME_RELEASE} exit 0 ;; + mac68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme88k:OpenBSD:*:*) + echo m88k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit 0 ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit 0 ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit 0 ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit 0 ;; - mips:*:5*:RISCos) + 2020:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit 0 ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + sed 's/^ //' << EOF >dummy.c + int main (argc, argv) int argc; char **argv; { + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + ${CC-cc} dummy.c -o dummy \ + && ./dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ + && rm dummy.c dummy && exit 0 + rm -f dummy.c dummy echo mips-mips-riscos${UNAME_RELEASE} exit 0 ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit 0 ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit 0 ;; @@ -127,12 +264,17 @@ echo m88k-motorola-sysv3 exit 0 ;; AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \ -o ${TARGET_BINARY_INTERFACE}x = x ] ; then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi + else echo i586-dg-dgux${UNAME_RELEASE} + fi exit 0 ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 @@ -150,10 +292,10 @@ *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit 0 ;; - ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' - i[34]86:AIX:*:*) + i?86:AIX:*:*) echo i386-ibm-aix exit 0 ;; *:AIX:2:3) @@ -198,7 +340,7 @@ echo romp-ibm-bsd4.4 exit 0 ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC NetBSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit 0 ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx @@ -216,7 +358,7 @@ case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; - 9000/7?? | 9000/8?[79] ) HP_ARCH=hppa1.1 ;; + 9000/7?? | 9000/8?[1679] ) HP_ARCH=hppa1.1 ;; 9000/8?? ) HP_ARCH=hppa1.0 ;; esac HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` @@ -264,6 +406,13 @@ hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit 0 ;; + i?86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit 0 ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit 0 ;; @@ -291,17 +440,33 @@ CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} exit 0 ;; - CRAY*C90:*:*:*) - echo c90-cray-unicos${UNAME_RELEASE} + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ + exit 0 ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} exit 0 ;; CRAY-2:*:*:*) echo cray2-cray-unicos exit 0 ;; + F300:UNIX_System_V:*:*) + FUJITSU_SYS=`uname -p | tr [A-Z] [a-z] | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit 0 ;; + F301:UNIX_System_V:*:*) + echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'` + exit 0 ;; hp3[0-9][05]:NetBSD:*:*) echo m68k-hp-netbsd${UNAME_RELEASE} exit 0 ;; - i[34]86:BSD/386:*:* | *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + hp300:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + i?86:BSD/386:*:* | *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit 0 ;; *:FreeBSD:*:*) echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` @@ -309,36 +474,150 @@ *:NetBSD:*:*) echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` exit 0 ;; + *:OpenBSD:*:*) + echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + exit 0 ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin32 + exit 0 ;; + i*:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit 0 ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin32 + exit 0 ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; *:GNU:*:*) - echo `echo ${UNAME_MACHINE}|sed -e 's,/.*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit 0 ;; *:Linux:*:*) + # uname on the ARM produces all sorts of strangeness, and we need to + # filter it out. + case "$UNAME_MACHINE" in + arm* | sa110*) UNAME_MACHINE="arm" ;; + esac + # The BFD linker knows what the default object file format is, so # first see if it will tell us. ld_help_string=`ld --help 2>&1` - if echo $ld_help_string | grep >/dev/null 2>&1 "supported emulations: elf_i[345]86"; then - echo "${UNAME_MACHINE}-unknown-linux" ; exit 0 - elif echo $ld_help_string | grep >/dev/null 2>&1 "supported emulations: i[345]86linux"; then - echo "${UNAME_MACHINE}-unknown-linuxaout" ; exit 0 - elif echo $ld_help_string | grep >/dev/null 2>&1 "supported emulations: i[345]86coff"; then - echo "${UNAME_MACHINE}-unknown-linuxcoff" ; exit 0 - elif test "${UNAME_MACHINE}" = "alpha" ; then - echo alpha-unknown-linux ; exit 0 - else - # Either a pre-BFD a.out linker (linuxoldld) or one that does not give us - # useful --help. Gcc wants to distinguish between linuxoldld and linuxaout. - test ! -d /usr/lib/ldscripts/. \ - && echo "${UNAME_MACHINE}-unknown-linuxoldld" && exit 0 + ld_supported_emulations=`echo $ld_help_string \ + | sed -ne '/supported emulations:/!d + s/[ ][ ]*/ /g + s/.*supported emulations: *// + s/ .*// + p'` + case "$ld_supported_emulations" in + i?86linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" ; exit 0 ;; + i?86coff) echo "${UNAME_MACHINE}-pc-linux-gnucoff" ; exit 0 ;; + sparclinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; + armlinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; + m68klinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; + elf32ppc) echo "powerpc-unknown-linux-gnu" ; exit 0 ;; + esac + + if test "${UNAME_MACHINE}" = "alpha" ; then + sed 's/^ //' <<EOF >dummy.s + .globl main + .ent main + main: + .frame \$30,0,\$26,0 + .prologue 0 + .long 0x47e03d80 # implver $0 + lda \$2,259 + .long 0x47e20c21 # amask $2,$1 + srl \$1,8,\$2 + sll \$2,2,\$2 + sll \$0,3,\$0 + addl \$1,\$0,\$0 + addl \$2,\$0,\$0 + ret \$31,(\$26),1 + .end main +EOF + LIBC="" + ${CC-cc} dummy.s -o dummy 2>/dev/null + if test "$?" = 0 ; then + ./dummy + case "$?" in + 7) + UNAME_MACHINE="alpha" + ;; + 15) + UNAME_MACHINE="alphaev5" + ;; + 14) + UNAME_MACHINE="alphaev56" + ;; + 10) + UNAME_MACHINE="alphapca56" + ;; + 16) + UNAME_MACHINE="alphaev6" + ;; + esac + + objdump --private-headers dummy | \ + grep ld.so.1 > /dev/null + if test "$?" = 0 ; then + LIBC="libc1" + fi + fi + rm -f dummy.s dummy + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0 + elif test "${UNAME_MACHINE}" = "mips" ; then + cat >dummy.c <<EOF +main(argc, argv) + int argc; + char *argv[]; +{ +#ifdef __MIPSEB__ + printf ("%s-unknown-linux-gnu\n", argv[1]); +#endif +#ifdef __MIPSEL__ + printf ("%sel-unknown-linux-gnu\n", argv[1]); +#endif + return 0; +} +EOF + ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0 + rm -f dummy.c dummy + else + # Either a pre-BFD a.out linker (linux-gnuoldld) + # or one that does not give us useful --help. + # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout. + # If ld does not provide *any* "supported emulations:" + # that means it is gnuoldld. + echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:" + test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0 + + case "${UNAME_MACHINE}" in + i?86) + VENDOR=pc; + ;; + *) + VENDOR=unknown; + ;; + esac # Determine whether the default compiler is a.out or elf cat >dummy.c <<EOF +#include <features.h> main(argc, argv) -int argc; -char *argv[]; + int argc; + char *argv[]; { #ifdef __ELF__ - printf ("%s-unknown-linux\n", argv[1]); +# ifdef __GLIBC__ +# if __GLIBC__ >= 2 + printf ("%s-${VENDOR}-linux-gnu\n", argv[1]); +# else + printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); +# endif +# else + printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); +# endif #else - printf ("%s-unknown-linuxaout\n", argv[1]); + printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]); #endif return 0; } @@ -348,30 +627,45 @@ fi ;; # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions # are messed up and put the nodename in both sysname and nodename. - i[34]86:DYNIX/ptx:4*:*) + i?86:DYNIX/ptx:4*:*) echo i386-sequent-sysv4 exit 0 ;; - i[34]86:*:4.*:* | i[34]86:SYSTEM_V:4.*:*) + i?86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit 0 ;; + i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*) if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE} else - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE} + echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE} fi exit 0 ;; - i[34]86:*:3.2:*) + i?86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name` - echo ${UNAME_MACHINE}-unknown-isc$UNAME_REL + echo ${UNAME_MACHINE}-pc-isc$UNAME_REL elif /bin/uname -X 2>/dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 - echo ${UNAME_MACHINE}-unknown-sco$UNAME_REL + (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else - echo ${UNAME_MACHINE}-unknown-sysv32 + echo ${UNAME_MACHINE}-pc-sysv32 fi exit 0 ;; + pc:*:*:*) + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. + echo i386-pc-msdosdjgpp + exit 0 ;; Intel:Mach:3*:*) - echo i386-unknown-mach3 + echo i386-pc-mach3 exit 0 ;; paragon:*:*:*) echo i860-intel-osf1 @@ -387,30 +681,36 @@ # "miniframe" echo m68010-convergent-sysv exit 0 ;; - M680[234]0:*:R3V[567]*:*) + M68*:*:R3V[567]*:*) test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) - uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4.3 && exit 0 - uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && echo i586-ncr-sysv4.3 && exit 0 ;; + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4.3${OS_REL} && exit 0 + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - uname -p 2>/dev/null | grep 86 >/dev/null \ + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4 && exit 0 ;; - m680[234]0:LynxOS:2.[23]*:*) - echo m68k-lynx-lynxos${UNAME_RELEASE} + m68*:LynxOS:2.*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} exit 0 ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit 0 ;; - i[34]86:LynxOS:2.[23]*:*) - echo i386-lynx-lynxos${UNAME_RELEASE} + i?86:LynxOS:2.*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} exit 0 ;; - TSUNAMI:LynxOS:2.[23]*:*) - echo sparc-lynx-lynxos${UNAME_RELEASE} + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; - rs6000:LynxOS:2.[23]*:*) - echo rs6000-lynx-lynxos${UNAME_RELEASE} + rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} exit 0 ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 @@ -423,6 +723,32 @@ echo ns32k-sni-sysv fi exit 0 ;; + PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says <Richard.M.Bartel@ccMail.Census.GOV> + echo i586-unisys-sysv4 + exit 0 ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes <hewes@openmarket.com>. + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit 0 ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit 0 ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit 0 ;; + news*:NEWS-OS:*:6*) + echo mips-sony-newsos6 + exit 0 ;; + R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit 0 ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 @@ -452,15 +778,6 @@ #endif #endif -#if defined (host_mips) && defined (MIPSEB) -#if defined (SYSTYPE_BSD43) - printf ("mips-mips-riscos4bsd\n"); exit (0); -#endif -#if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos4sysv\n"); exit (0); -#endif -#endif - #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix"); exit (0); #endif @@ -475,7 +792,7 @@ #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; - printf ("%s-next-nextstep%s\n", __ARCHITECTURE__, version==2 ? "2" : "3"); + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); exit (0); #endif @@ -492,7 +809,7 @@ #endif #if defined (__386BSD__) - printf ("i386-unknown-bsd\n"); exit (0); + printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) --- config.sub +++ config.sub 2000/11/28 00:21:30 @@ -1,9 +1,9 @@ #! /bin/sh # Configuration validation subroutine script, version 1.1. -# Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. +# Copyright (C) 1991, 92-97, 1998 Free Software Foundation, Inc. # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software -# can handle that machine. It does not imply ALL GNU software can. +# can handle that machine. It does not imply ALL GNU software can. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -41,6 +41,8 @@ # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. if [ x$1 = x ] @@ -62,11 +64,21 @@ ;; esac -# Separate what the user gave into CPU-COMPANY and OS (if any). -basic_machine=`echo $1 | sed 's/-[^-]*$//'` -if [ $basic_machine != $1 ] -then os=`echo $1 | sed 's/.*-/-/'` -else os=; fi +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + linux-gnu*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also @@ -81,38 +93,43 @@ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp ) + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple) os= basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; + -sco5) + os=sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; -sco4) os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos @@ -123,35 +140,49 @@ -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; + -psos*) + os=-psos + ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. - tahoe | i[345]86 | i860 | m68k | m68000 | m88k | ns32k | arm \ - | arme[lb] | pyramid \ - | tron | a29k | 580 | i960 | h8300 | hppa1.0 | hppa1.1 \ - | alpha | we32k | ns16k | clipper | sparclite | i370 | sh \ - | powerpc | powerpcle | sparc64 | 1750a | dsp16xx | mips64 | mipsel \ - | pdp11 | mips64el | mips64orion | mips64orionel \ - | sparc) + tahoe | i860 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \ + | arme[lb] | pyramid | mn10200 | mn10300 \ + | tron | a29k | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 \ + | alpha | alphaev5 | alphaev56 | we32k | ns16k | clipper \ + | i370 | sh | powerpc | powerpcle | 1750a | dsp16xx | pdp11 \ + | mips64 | mipsel | mips64el | mips64orion | mips64orionel \ + | mipstx39 | mipstx39el \ + | sparc | sparclet | sparclite | sparc64 | v850) basic_machine=$basic_machine-unknown ;; + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i[34567]86) + basic_machine=$basic_machine-pc + ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. - vax-* | tahoe-* | i[345]86-* | i860-* | m68k-* | m68000-* | m88k-* \ - | sparc-* | ns32k-* | fx80-* | arm-* | c[123]* \ - | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* | power-* \ - | none-* | 580-* | cray2-* | h8300-* | i960-* | xmp-* | ymp-* \ - | hppa1.0-* | hppa1.1-* | alpha-* | we32k-* | cydra-* | ns16k-* \ - | pn-* | np1-* | xps100-* | clipper-* | orion-* | sparclite-* \ - | pdp11-* | sh-* | powerpc-* | powerpcle-* | sparc64-* | mips64-* | mipsel-* \ - | mips64el-* | mips64orion-* | mips64orionel-*) + vax-* | tahoe-* | i[34567]86-* | i860-* | m32r-* | m68k-* | m68000-* \ + | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \ + | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \ + | power-* | none-* | 580-* | cray2-* | h8300-* | i960-* \ + | xmp-* | ymp-* | hppa-* | hppa1.0-* | hppa1.1-* \ + | alpha-* | alphaev5-* | alphaev56-* | we32k-* | cydra-* \ + | ns16k-* | pn-* | np1-* | xps100-* | clipper-* | orion-* \ + | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \ + | sparc64-* | mips64-* | mipsel-* \ + | mips64el-* | mips64orion-* | mips64orionel-* \ + | mipstx39-* | mipstx39el-* \ + | f301-*) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. @@ -178,9 +209,9 @@ amiga | amiga-*) basic_machine=m68k-cbm ;; - amigados) + amigaos | amigados) basic_machine=m68k-cbm - os=-amigados + os=-amigaos ;; amigaunix | amix) basic_machine=m68k-cbm @@ -190,6 +221,10 @@ basic_machine=m68k-apollo os=-sysv ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; balance) basic_machine=ns32k-sequent os=-dynix @@ -222,6 +257,10 @@ basic_machine=cray2-cray os=-unicos ;; + [ctj]90-cray) + basic_machine=c90-cray + os=-unicos + ;; crds | unos) basic_machine=m68k-crds ;; @@ -303,25 +342,28 @@ hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; + hppa-next) + os=-nextstep3 + ;; i370-ibm* | ibm*) basic_machine=i370-ibm os=-mvs ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? - i[345]86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-unknown/'` + i[34567]86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; - i[345]86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-unknown/'` + i[34567]86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; - i[345]86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-unknown/'` + i[34567]86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; - i[345]86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-unknown/'` + i[34567]86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; iris | iris4d) @@ -352,6 +394,14 @@ miniframe) basic_machine=m68000-convergent ;; + mipsel*-linux*) + basic_machine=mipsel-unknown + os=-linux-gnu + ;; + mips*-linux*) + basic_machine=mips-unknown + os=-linux-gnu + ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; @@ -419,21 +469,23 @@ pc532 | pc532-*) basic_machine=ns32k-pc532 ;; - pentium | p5 | p6) - # We don't have specific support for the Intel Pentium (p6) followon yet, so just call it a Pentium - basic_machine=i586-intel + pentium | p5 | k5 | nexen) + basic_machine=i586-pc + ;; + pentiumpro | p6 | k6 | 6x86) + basic_machine=i686-pc + ;; + pentiumii | pentium2) + basic_machine=i786-pc ;; - pentium-* | p5-* | p6-*) - # We don't have specific support for the Intel Pentium (p6) followon yet, so just call it a Pentium + pentium-* | p5-* | k5-* | nexen-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; - k5) - # We don't have specific support for AMD's K5 yet, so just call it a Pentium - basic_machine=i586-amd - ;; - nexen) - # We don't have specific support for Nexgen yet, so just call it a Pentium - basic_machine=i586-nexgen + pentiumpro-* | p6-* | k6-* | 6x86-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould @@ -517,6 +569,12 @@ basic_machine=i386-sequent os=-dynix ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; tower | tower-32) basic_machine=m68k-ncr ;; @@ -536,6 +594,9 @@ basic_machine=vax-dec os=-vms ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; vxworks960) basic_machine=i960-wrs os=-vxworks @@ -563,7 +624,11 @@ # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. mips) - basic_machine=mips-mips + if [ x$os = x-linux-gnu ]; then + basic_machine=mips-unknown + else + basic_machine=mips-mips + fi ;; romp) basic_machine=romp-ibm @@ -615,6 +680,8 @@ if [ x"$os" != x"" ] then case $os in + # First match some system type aliases + # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` @@ -622,28 +689,37 @@ -solaris) os=-solaris2 ;; - -unixware* | svr4*) + -svr4*) os=-sysv4 ;; + -unixware*) + os=-sysv4.2uw + ;; -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux|'` + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[345]* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ - | -amigados* | -msdos* | -newsos* | -unicos* | -aos* \ - | -nindy* | -vxworks* | -ebmon* | -hms* | -mvs* | -clix* \ - | -riscos* | -linux* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -netbsd* | -freebsd* | -riscix* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* ) + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -cygwin32* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -uxpv*) # Remember, each alternative MUST END IN *, to match a version number. ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; @@ -668,6 +744,9 @@ -ctix* | -uts*) os=-sysv ;; + -ns2 ) + os=-nextstep2 + ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` @@ -761,7 +840,7 @@ os=-sysv ;; *-cbm) - os=-amigados + os=-amigaos ;; *-dg) os=-dgux @@ -775,6 +854,9 @@ m88k-omron*) os=-luna ;; + *-next ) + os=-nextstep + ;; *-sequent) os=-ptx ;; @@ -808,6 +890,9 @@ *-masscomp) os=-rtu ;; + f301-fujitsu) + os=-uxpv + ;; *) os=-none ;; @@ -826,9 +911,6 @@ -sunos*) vendor=sun ;; - -lynxos*) - vendor=lynx - ;; -aix*) vendor=ibm ;; @@ -856,8 +938,11 @@ -ptx*) vendor=sequent ;; - -vxworks*) + -vxsim* | -vxworks*) vendor=wrs + ;; + -aux*) + vendor=apple ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` --- configure +++ configure 2000/11/28 00:21:30 @@ -2783,7 +2783,7 @@ echo $ac_n "checking location of spool directory""... $ac_c" 1>&6 echo "configure:2786: checking location of spool directory" >&5 -if test -d /var/spool/atjobs ; then +if test -d /var/spool ; then sp=/var/spool cat >> confdefs.h <<\EOF #define SPOOLDIR "/var/spool" --- daemon.c +++ daemon.c 2000/11/28 00:21:30 @@ -72,7 +72,7 @@ va_list args; va_start(args, fmt); - vsprintf(buf, fmt, args); + vsnprintf(buf, sizeof(buf), fmt, args); va_end(args); if (daemon_debug) { @@ -90,7 +90,7 @@ va_list args; va_start(args, fmt); - vsprintf(buf, fmt, args); + vsnprintf(buf, sizeof(buf), fmt, args); va_end(args); if (daemon_debug) { @@ -127,6 +127,7 @@ } } old_umask = umask(S_IWGRP | S_IWOTH); + (void) setsid(); PRIV_START --- lex.yy.c +++ lex.yy.c 2000/11/28 00:21:30 @@ -1,7 +1,7 @@ /* A lexical scanner generated by flex */ /* Scanner skeleton version: - * $Header: /home/ig25/at-3.1.8/RCS/lex.yy.c,v 1.4 1997/09/28 20:00:22 ig25 Exp $ + * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $ */ #define FLEX_SCANNER @@ -126,6 +126,7 @@ { \ /* Undo effects of setting up yytext. */ \ *yy_cp = yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ @@ -235,7 +236,7 @@ #define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); -YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *str )); +YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); static void *yy_flex_alloc YY_PROTO(( yy_size_t )); @@ -456,6 +457,7 @@ #define REJECT reject_used_but_not_detected #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET char *yytext; #line 1 "parsetime.l" #define INITIAL 0 @@ -491,7 +493,7 @@ result = 1; \ } \ } while(0) -#line 495 "lex.yy.c" +#line 497 "lex.yy.c" /* Macros after this point can all be overridden by user definitions in * section 1. @@ -513,6 +515,10 @@ static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); #endif +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen YY_PROTO(( yyconst char * )); +#endif + #ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput YY_PROTO(( void )); @@ -641,7 +647,7 @@ #line 36 "parsetime.l" -#line 645 "lex.yy.c" +#line 651 "lex.yy.c" if ( yy_init ) { @@ -919,7 +925,7 @@ #line 77 "parsetime.l" ECHO; YY_BREAK -#line 923 "lex.yy.c" +#line 929 "lex.yy.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -930,6 +936,7 @@ /* Undo the effects of YY_DO_BEFORE_ACTION. */ *yy_cp = yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) { @@ -1075,7 +1082,7 @@ { /* Don't try to fill the buffer, so this is an EOF. */ if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) { - /* We matched a singled characater, the EOB, so + /* We matched a single character, the EOB, so * treat this as a final EOF. */ return EOB_ACT_END_OF_FILE; @@ -1102,7 +1109,7 @@ /* don't do the read, it's not guaranteed to return an EOF, * just force an EOF */ - yy_n_chars = 0; + yy_current_buffer->yy_n_chars = yy_n_chars = 0; else { @@ -1157,6 +1164,8 @@ /* Read in more data. */ YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), yy_n_chars, num_to_read ); + + yy_current_buffer->yy_n_chars = yy_n_chars; } if ( yy_n_chars == 0 ) @@ -1281,7 +1290,8 @@ yy_cp += (int) (dest - source); yy_bp += (int) (dest - source); - yy_n_chars = yy_current_buffer->yy_buf_size; + yy_current_buffer->yy_n_chars = + yy_n_chars = yy_current_buffer->yy_buf_size; if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) YY_FATAL_ERROR( "flex scanner push-back overflow" ); @@ -1319,19 +1329,31 @@ else { /* need more input */ - yytext_ptr = yy_c_buf_p; + int offset = yy_c_buf_p - yytext_ptr; ++yy_c_buf_p; switch ( yy_get_next_buffer() ) { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /* fall through */ + case EOB_ACT_END_OF_FILE: { if ( yywrap() ) - { - yy_c_buf_p = - yytext_ptr + YY_MORE_ADJ; return EOF; - } if ( ! yy_did_buffer_switch_on_eof ) YY_NEW_FILE; @@ -1343,17 +1365,8 @@ } case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; + yy_c_buf_p = yytext_ptr + offset; break; - - case EOB_ACT_LAST_MATCH: -#ifdef __cplusplus - YY_FATAL_ERROR( - "unexpected last match in yyinput()" ); -#else - YY_FATAL_ERROR( - "unexpected last match in input()" ); -#endif } } } @@ -1517,6 +1530,9 @@ #endif { + if ( ! b ) + return; + b->yy_n_chars = 0; /* We always need two end-of-buffer characters. The first causes @@ -1576,17 +1592,17 @@ #ifndef YY_NO_SCAN_STRING #ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_string( yyconst char *str ) +YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) #else -YY_BUFFER_STATE yy_scan_string( str ) -yyconst char *str; +YY_BUFFER_STATE yy_scan_string( yy_str ) +yyconst char *yy_str; #endif { int len; - for ( len = 0; str[len]; ++len ) + for ( len = 0; yy_str[len]; ++len ) ; - return yy_scan_bytes( str, len ); + return yy_scan_bytes( yy_str, len ); } #endif @@ -1707,7 +1723,7 @@ { \ /* Undo effects of setting up yytext. */ \ yytext[yyleng] = yy_hold_char; \ - yy_c_buf_p = yytext + n - YY_MORE_ADJ; \ + yy_c_buf_p = yytext + n; \ yy_hold_char = *yy_c_buf_p; \ *yy_c_buf_p = '\0'; \ yyleng = n; \ @@ -1730,6 +1746,22 @@ register int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; + } +#endif + +#ifdef YY_NEED_STRLEN +#ifdef YY_USE_PROTOS +static int yy_flex_strlen( yyconst char *s ) +#else +static int yy_flex_strlen( s ) +yyconst char *s; +#endif + { + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; } #endif --- panic.c +++ panic.c 2000/11/28 00:21:30 @@ -41,6 +41,7 @@ /* Local headers */ #include "panic.h" +#include "privs.h" #include "at.h" /* File scope variables */ @@ -72,12 +73,15 @@ va_list args; va_start(args, fmt); - vsprintf(buf, fmt, args); + vsnprintf(buf, sizeof(buf), fmt, args); va_end(args); perror(buf); - if (fcreated) + if (fcreated) { + PRIV_START unlink(atfile); + PRIV_END + } exit(EXIT_FAILURE); } @@ -88,7 +92,7 @@ /* Print usage and exit. */ fprintf(stderr, "Usage: at [-V] [-q x] [-f file] [-m] time\n" - " atq [-V] [-q x] [-v]\n" + " atq [-V] [-q x]\n" " atrm [-V] [-q x] job ...\n" " batch [-V] [-f file] [-m]\n"); exit(EXIT_FAILURE); --- parsetime.y +++ parsetime.y 2000/11/28 00:21:30 @@ -11,6 +11,9 @@ static int isgmt; static int time_only; +extern int yyerror(char *s); +extern int yylex(); + int add_date(int number, int period); %} @@ -36,26 +39,31 @@ %start timespec %% -timespec : time +timespec : date + | time { time_only = 1; } | time date - | time increment - | time date increment - | time decrement - | time date decrement + | time_or_not inc_or_dec + | time_or_not date inc_or_dec | nowspec ; nowspec : now - | now increment - | now decrement + | now inc_or_dec ; now : NOW + | TOMORROW + { + add_date(1, DAY); + } ; +time_or_not : time + | + time : hr24clock_hr_min | hr24clock_hr_min timezone_name | hr24clock_hour time_sep minute @@ -83,10 +91,11 @@ ; date : month_name day_number + | month_name day_number year_number | month_name day_number ',' year_number | day_of_week { - add_date ((7 + $1 - exectm.tm_wday) %7 + 1, DAY); + add_date ((6 + $1 - exectm.tm_wday) %7 + 1, DAY); } | TODAY | TOMORROW @@ -101,6 +110,9 @@ | month_number '/' day_number '/' year_number ; +inc_or_dec : increment + | decrement + increment : '+' inc_number inc_period { add_date($2, $3); @@ -131,11 +143,57 @@ hr24clock_hr_min: INT { - exectm.tm_min = -1; - exectm.tm_hour = -1; if (strlen($1) == 4) { + exectm.tm_min = -1; + exectm.tm_hour = -1; sscanf($1, "%2d %2d", &exectm.tm_hour, &exectm.tm_min); + } else if (strlen($1) >= 5 && strlen($1) <= 8) { + /* Ok, this is a kluge. I hate design errors... -Joey */ + char shallot[5]; + char *onion; + + onion=$1; + memset (shallot, 0, sizeof (shallot)); + if (strlen($1) == 5 || strlen($1) == 7) { + strncpy (shallot,onion,1); + onion++; + } else { + strncpy (shallot,onion,2); + onion+=2; + } + sscanf(shallot, "%d", &exectm.tm_mon); + + if (exectm.tm_mon < 1 || exectm.tm_mon > 12) { + yyerror("Error in month number"); + YYERROR; + } + exectm.tm_mon--; + + memset (shallot, 0, sizeof (shallot)); + strncpy (shallot,onion,2); + sscanf(shallot, "%d", &exectm.tm_mday); + if (exectm.tm_mday < 0 || exectm.tm_mday > 31) + { + yyerror("Error in day of month"); + YYERROR; + } + + onion+=2; + memset (shallot, 0, sizeof (shallot)); + strncpy (shallot,onion,4); + if ( sscanf(shallot, "%d", &exectm.tm_year) != 1) { + yyerror("Error in year"); + YYERROR; + } + if (exectm.tm_year < 70) { + exectm.tm_year += 100; + } + else if (exectm.tm_year > 1900) { + exectm.tm_year -= 1900; + } + + free ($1); } else { sscanf($1, "%d", &exectm.tm_hour); @@ -148,7 +206,7 @@ YYERROR; } if (exectm.tm_hour > 24 || exectm.tm_hour < 0) { - yyerror("Problem in minutes specification"); + yyerror("Problem in hours specification"); YYERROR; } } @@ -181,6 +239,15 @@ ; am_pm : AM + { + if (exectm.tm_hour > 12) { + yyerror("Hour too large for AM"); + YYERROR; + } + else if (exectm.tm_hour == 12) { + exectm.tm_hour = 0; + } + } | PM { if (exectm.tm_hour > 12) { @@ -319,6 +386,24 @@ } #ifdef TEST_PARSER +/* + +Here are some lines to test: + +./parsetest 7AM Mar 24 2000 +./parsetest 7AM Mar 24 00 +./parsetest 7AM 032400 +./parsetest 7AM 03/24/00 +./parsetest 7AM 24.03.00 +./parsetest 7AM Mar 24 + +./parsetest 03242000 +./parsetest noon 03242000 +./parsetest 5:30 +./parsetest 4pm + 3 days +./parsetest 10am Jul 31 + + */ int main(int argc, char **argv) { --- rc.at +++ rc.at 2000/11/28 00:22:42 @@ -0,0 +1,58 @@ +#! /bin/sh +# Copyright (c) 1996 S.u.S.E. Gmbh Fuerth, Germany. All rights reserved. +# +# Author: Burchard Steinbild <bs@suse.de>, 1996 +# +### BEGIN INIT INFO +# Provides: at +# Required-Start: route nfs +# Required-Stop: +# Default-Start: 2 3 5 +# Default-Stop: +# Description: AT batch job daemon +### END INIT INFO + + +. /etc/rc.config + +# Determine the base and follow a runlevel link name. +base=${0##*/} +link=${base#*[SK][0-9][0-9]} + +# Force execution if not called by a runlevel directory. +test $link = $base && START_ATD=yes +test "$START_ATD" = yes || exit 0 + +# The echo return value for success (defined in /etc/rc.config). +return=$rc_done +case "$1" in + start) + echo -n "Starting service at daemon:" + startproc /usr/sbin/atd || return=$rc_failed + echo -e "$return" + ;; + stop) + echo -n "Shutting down service at daemon:" + killproc -TERM /usr/sbin/atd || return=$rc_failed + echo -e "$return" + ;; + status) + echo -n "Checking for service at deamon: " + checkproc /usr/sbin/atd && echo OK || echo No process + ;; + reload) + $0 stop && $0 start || return=$rc_failed + ;; + restart) + $0 stop && $0 start || return=$rc_failed + ;; + *) + echo "Usage: $0 {start|stop|status|restart|reload}" + exit 1 + ;; +esac + +# Inform the caller not only verbosely and set an exit status. +test "$return" = "$rc_done" || exit 1 +exit 0 + --- rc.config.at +++ rc.config.at 2000/11/28 00:21:30 @@ -0,0 +1,5 @@ +# +# Should the ATD (at daemon) be started, for the execution of at jobs? (yes/no) +# +START_ATD=yes + --- y.tab.c +++ y.tab.c 2000/11/28 00:21:30 @@ -1,5 +1,5 @@ -/* A Bison parser, made from parsetime.y with Bison version GNU Bison version 1.22 +/* A Bison parser, made from parsetime.y with Bison version GNU Bison version 1.24 */ #define YYBISON 1 /* Identify Bison output. */ @@ -55,9 +55,12 @@ static int isgmt; static int time_only; +extern int yyerror(char *s); +extern int yylex(); + int add_date(int number, int period); -#line 17 "parsetime.y" +#line 20 "parsetime.y" typedef union { char * charval; int intval; @@ -89,11 +92,11 @@ -#define YYFINAL 100 +#define YYFINAL 104 #define YYFLAG -32768 #define YYNTBASE 47 -#define YYTRANSLATE(x) ((unsigned)(x) <= 293 ? yytranslate[x] : 67) +#define YYTRANSLATE(x) ((unsigned)(x) <= 293 ? yytranslate[x] : 69) static const char yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -130,167 +133,190 @@ #if YYDEBUG != 0 static const short yyprhs[] = { 0, - 0, 2, 5, 8, 12, 15, 19, 21, 23, 26, - 29, 31, 33, 36, 40, 45, 48, 52, 57, 63, - 65, 67, 69, 72, 77, 79, 81, 83, 89, 95, - 99, 102, 106, 112, 116, 119, 122, 126, 128, 130, - 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, - 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, - 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, - 192, 194, 196, 198, 200, 202, 204 + 0, 2, 4, 7, 10, 14, 16, 18, 21, 23, + 25, 27, 28, 30, 33, 37, 42, 45, 49, 54, + 60, 62, 64, 66, 69, 73, 78, 80, 82, 84, + 90, 96, 100, 103, 107, 113, 115, 117, 119, 123, + 126, 129, 133, 135, 137, 139, 141, 143, 145, 147, + 149, 151, 153, 155, 157, 159, 161, 163, 165, 167, + 169, 171, 173, 175, 177, 179, 181, 183, 185, 187, + 189, 191, 193, 195, 197, 199, 201, 203, 205, 207, + 209, 211 }; -static const short yyrhs[] = { 50, - 0, 50, 51, 0, 50, 52, 0, 50, 51, 52, - 0, 50, 53, 0, 50, 51, 53, 0, 48, 0, - 49, 0, 49, 52, 0, 49, 53, 0, 4, 0, - 55, 0, 55, 56, 0, 57, 66, 58, 0, 57, - 66, 58, 56, 0, 57, 59, 0, 57, 59, 56, - 0, 57, 66, 58, 59, 0, 57, 66, 58, 59, - 56, 0, 7, 0, 8, 0, 9, 0, 60, 62, - 0, 60, 62, 39, 63, 0, 64, 0, 17, 0, - 18, 0, 63, 40, 61, 40, 62, 0, 62, 41, - 61, 41, 63, 0, 62, 41, 61, 0, 62, 60, - 0, 62, 60, 63, 0, 61, 42, 62, 42, 63, - 0, 43, 65, 54, 0, 19, 54, 0, 19, 64, - 0, 40, 65, 54, 0, 20, 0, 21, 0, 22, - 0, 23, 0, 24, 0, 25, 0, 3, 0, 38, - 0, 55, 0, 3, 0, 5, 0, 6, 0, 26, - 0, 27, 0, 28, 0, 29, 0, 30, 0, 31, - 0, 32, 0, 33, 0, 34, 0, 35, 0, 36, - 0, 37, 0, 3, 0, 3, 0, 3, 0, 10, - 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, - 0, 16, 0, 3, 0, 44, 0, 45, 0, 41, - 0, 46, 0, 39, 0 +static const short yyrhs[] = { 52, + 0, 51, 0, 51, 52, 0, 50, 53, 0, 50, + 52, 53, 0, 48, 0, 49, 0, 49, 53, 0, + 4, 0, 18, 0, 51, 0, 0, 57, 0, 57, + 58, 0, 59, 68, 60, 0, 59, 68, 60, 58, + 0, 59, 61, 0, 59, 61, 58, 0, 59, 68, + 60, 61, 0, 59, 68, 60, 61, 58, 0, 7, + 0, 8, 0, 9, 0, 62, 64, 0, 62, 64, + 65, 0, 62, 64, 39, 65, 0, 66, 0, 17, + 0, 18, 0, 65, 40, 63, 40, 64, 0, 64, + 41, 63, 41, 65, 0, 64, 41, 63, 0, 64, + 62, 0, 64, 62, 65, 0, 63, 42, 64, 42, + 65, 0, 3, 0, 54, 0, 55, 0, 43, 67, + 56, 0, 19, 56, 0, 19, 66, 0, 40, 67, + 56, 0, 20, 0, 21, 0, 22, 0, 23, 0, + 24, 0, 25, 0, 3, 0, 38, 0, 57, 0, + 3, 0, 5, 0, 6, 0, 26, 0, 27, 0, + 28, 0, 29, 0, 30, 0, 31, 0, 32, 0, + 33, 0, 34, 0, 35, 0, 36, 0, 37, 0, + 3, 0, 3, 0, 3, 0, 11, 0, 12, 0, + 13, 0, 14, 0, 15, 0, 16, 0, 10, 0, + 3, 0, 44, 0, 45, 0, 41, 0, 46, 0, + 39, 0 }; #endif #if YYDEBUG != 0 static const short yyrline[] = { 0, - 39, 43, 44, 45, 46, 47, 48, 51, 52, 53, - 56, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 72, 78, 85, 86, 87, 91, 92, 96, 97, 98, - 99, 100, 101, 104, 108, 112, 118, 124, 125, 126, - 127, 128, 129, 132, 157, 170, 173, 183, 184, 197, - 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, - 208, 211, 225, 238, 261, 262, 263, 264, 265, 266, - 267, 270, 280, 281, 282, 283, 284 + 42, 43, 47, 48, 49, 50, 53, 54, 57, 58, + 64, 65, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 80, 86, 93, 94, 95, 96, 100, 101, 105, + 106, 107, 108, 109, 110, 111, 158, 159, 161, 165, + 169, 175, 181, 182, 183, 184, 185, 186, 189, 255, + 268, 271, 281, 291, 304, 305, 306, 307, 308, 309, + 310, 311, 312, 313, 314, 315, 318, 332, 345, 368, + 369, 370, 371, 372, 373, 374, 377, 387, 388, 389, + 390, 391 }; -static const char * const yytname[] = { "$","error","$illegal.","INT","NOW", +static const char * const yytname[] = { "$","error","$undefined.","INT","NOW", "AM","PM","NOON","MIDNIGHT","TEATIME","SUN","MON","TUE","WED","THU","FRI","SAT", "TODAY","TOMORROW","NEXT","MINUTE","HOUR","DAY","WEEK","MONTH","YEAR","JAN", "FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC","WORD","','", -"'-'","'.'","'/'","'+'","':'","'\\''","'h'","timespec","nowspec","now","time", -"date","increment","decrement","inc_period","hr24clock_hr_min","timezone_name", -"hr24clock_hour","minute","am_pm","month_name","month_number","day_number","year_number", -"day_of_week","inc_number","time_sep","" +"'-'","'.'","'/'","'+'","':'","'\\''","'h'","timespec","nowspec","now","time_or_not", +"time","date","inc_or_dec","increment","decrement","inc_period","hr24clock_hr_min", +"timezone_name","hr24clock_hour","minute","am_pm","month_name","month_number", +"day_number","year_number","day_of_week","inc_number","time_sep","" }; #endif static const short yyr1[] = { 0, - 47, 47, 47, 47, 47, 47, 47, 48, 48, 48, - 49, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 47, 47, 47, 47, 47, 47, 48, 48, 49, 49, 50, 50, 51, 51, 51, 51, 51, 51, 51, 51, - 51, 51, 51, 52, 52, 52, 53, 54, 54, 54, - 54, 54, 54, 55, 56, 57, 58, 59, 59, 60, - 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, - 60, 61, 62, 63, 64, 64, 64, 64, 64, 64, - 64, 65, 66, 66, 66, 66, 66 + 51, 51, 51, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 53, 53, 54, 54, + 54, 55, 56, 56, 56, 56, 56, 56, 57, 58, + 59, 60, 61, 61, 62, 62, 62, 62, 62, 62, + 62, 62, 62, 62, 62, 62, 63, 64, 65, 66, + 66, 66, 66, 66, 66, 66, 67, 68, 68, 68, + 68, 68 }; static const short yyr2[] = { 0, - 1, 2, 2, 3, 2, 3, 1, 1, 2, 2, - 1, 1, 2, 3, 4, 2, 3, 4, 5, 1, - 1, 1, 2, 4, 1, 1, 1, 5, 5, 3, - 2, 3, 5, 3, 2, 2, 3, 1, 1, 1, + 1, 1, 2, 2, 3, 1, 1, 2, 1, 1, + 1, 0, 1, 2, 3, 4, 2, 3, 4, 5, + 1, 1, 1, 2, 3, 4, 1, 1, 1, 5, + 5, 3, 2, 3, 5, 1, 1, 1, 3, 2, + 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1 + 1, 1 }; -static const short yydefact[] = { 0, - 44, 11, 20, 21, 22, 7, 8, 1, 12, 0, - 0, 0, 0, 9, 10, 63, 65, 66, 67, 68, - 69, 70, 71, 26, 27, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 2, 3, 5, - 0, 0, 0, 0, 25, 45, 13, 48, 49, 77, - 75, 73, 74, 76, 16, 0, 38, 39, 40, 41, - 42, 43, 35, 36, 72, 0, 0, 4, 6, 63, - 23, 0, 0, 31, 0, 17, 47, 14, 37, 34, - 0, 0, 62, 30, 64, 32, 0, 15, 18, 24, - 0, 0, 0, 19, 33, 29, 28, 0, 0, 0 +static const short yydefact[] = { 12, + 49, 9, 21, 22, 23, 76, 70, 71, 72, 73, + 74, 75, 28, 10, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 6, 7, 0, 11, + 1, 13, 0, 0, 0, 0, 0, 27, 0, 0, + 0, 8, 37, 38, 68, 29, 0, 4, 3, 50, + 14, 53, 54, 82, 80, 78, 79, 81, 17, 0, + 68, 24, 0, 0, 33, 0, 43, 44, 45, 46, + 47, 48, 40, 41, 77, 0, 0, 5, 18, 52, + 15, 69, 0, 25, 0, 67, 32, 34, 0, 42, + 39, 16, 19, 26, 0, 0, 0, 20, 35, 31, + 30, 0, 0, 0 }; -static const short yydefgoto[] = { 98, - 6, 7, 8, 38, 14, 15, 63, 9, 47, 10, - 78, 55, 41, 42, 43, 44, 45, 66, 56 +static const short yydefgoto[] = { 102, + 27, 28, 29, 30, 31, 42, 43, 44, 73, 32, + 51, 33, 81, 59, 34, 35, 36, 37, 38, 76, + 60 }; -static const short yypact[] = { 8, --32768,-32768,-32768,-32768,-32768,-32768, -14, 43, -4, 4, - 80, 5, 5,-32768,-32768, -12,-32768,-32768,-32768,-32768, +static const short yypact[] = { 128, + 3,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, --32768,-32768,-32768,-32768,-32768,-32768,-32768, -14,-32768,-32768, - 10, -6, 81, -8,-32768,-32768,-32768,-32768,-32768,-32768, --32768,-32768,-32768,-32768, 9, 48,-32768,-32768,-32768,-32768, --32768,-32768,-32768,-32768,-32768, -2, -2,-32768,-32768,-32768, - 25, 10, 63, 64, 63,-32768,-32768, 1,-32768,-32768, - 64, 26,-32768, 41,-32768,-32768, 44,-32768, 9,-32768, - 64, 64, 10,-32768,-32768,-32768,-32768, 85, 87,-32768 +-32768,-32768,-32768,-32768,-32768,-32768,-32768, -15, 55, 93, +-32768, 8, 16, 4, -31, 140, -21,-32768, 172, 21, + 21,-32768,-32768,-32768, 1,-32768, -15,-32768,-32768,-32768, +-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 18, 23, +-32768, -1, 4, 34, 56, 34,-32768,-32768,-32768,-32768, +-32768,-32768,-32768,-32768,-32768, 11, 11,-32768,-32768,-32768, + 10,-32768, 56,-32768, 22,-32768, 35,-32768, 37,-32768, +-32768,-32768, 18,-32768, 56, 56, 4,-32768,-32768,-32768, +-32768, 75, 78,-32768 }; static const short yypgoto[] = {-32768, --32768,-32768,-32768,-32768, -5, 6, -42,-32768, -51,-32768, --32768, 11, 54, -10, -41, 7, 95, 106,-32768 +-32768,-32768,-32768,-32768, -12, -24,-32768,-32768, -26,-32768, + -51,-32768,-32768, -2, 44, -54, -34, -56, 58, 53, +-32768 }; -#define YYLAST 122 +#define YYLAST 197 -static const short yytable[] = { 71, - -46, -46, 39, 76, 11, 48, 49, 65, 48, 49, - 1, 2, 70, 40, 3, 4, 5, 57, 58, 59, - 60, 61, 62, 79, 80, 12, 88, -64, 13, -62, - 82, 75, 68, 46, -46, 72, -46, 94, 46, -46, - -46, -46, 50, 69, 51, 16, 46, 52, 53, 54, - 77, 97, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 11, 84, 81, 87, 83, 85, 91, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, - 86, 92, 12, 93, 99, 13, 100, 90, 89, 17, - 18, 19, 20, 21, 22, 23, 74, 95, 96, 57, - 58, 59, 60, 61, 62, 64, 26, 27, 28, 29, - 30, 31, 32, 33, 34, 35, 36, 37, 67, 0, - 0, 73 +static const short yytable[] = { 62, + -36, 82, -36, 39, 48, 84, 61, 79, 88, 87, + 63, 89, -51, -51, 52, 53, 47, 49, 66, -36, + 52, 53, 78, 75, 40, 80, 94, 41, 85, 92, + 67, 68, 69, 70, 71, 72, 86, 83, 99, 100, + -36, 98, -67, -36, -67, 50, -51, 50, -51, 90, + 91, -51, -51, -51, 54, 50, 55, 45, 82, 56, + 57, 58, 101, 95, 6, 7, 8, 9, 10, 11, + 12, 13, 46, 39, 103, 96, 97, 104, 93, 65, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, -2, 77, 40, 45, 74, 41, 0, 0, + 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, + 46, 0, 0, 0, 0, 0, 0, 0, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 1, 2, 0, 0, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 0, 0, 0, 0, + 0, 0, 0, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 0, 0, 0, + 64, 6, 7, 8, 9, 10, 11, 12, 0, 0, + 0, 67, 68, 69, 70, 71, 72 }; -static const short yycheck[] = { 41, - 5, 6, 8, 55, 19, 5, 6, 3, 5, 6, - 3, 4, 3, 8, 7, 8, 9, 20, 21, 22, - 23, 24, 25, 66, 67, 40, 78, 40, 43, 42, - 72, 40, 38, 38, 39, 42, 41, 89, 38, 44, - 45, 46, 39, 38, 41, 3, 38, 44, 45, 46, - 3, 93, 10, 11, 12, 13, 14, 15, 16, 17, - 18, 19, 73, 39, 75, 3, 3, 42, 26, 27, +static const short yycheck[] = { 34, + 0, 3, 0, 19, 29, 62, 3, 59, 65, 64, + 42, 66, 5, 6, 5, 6, 29, 30, 40, 19, + 5, 6, 47, 3, 40, 3, 83, 43, 63, 81, + 20, 21, 22, 23, 24, 25, 3, 39, 95, 96, + 40, 93, 42, 43, 42, 38, 39, 38, 41, 76, + 77, 44, 45, 46, 39, 38, 41, 3, 3, 44, + 45, 46, 97, 42, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 0, 41, 40, 0, 81, 36, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + 36, 37, 0, 41, 40, 3, 39, 43, -1, -1, + -1, -1, 10, 11, 12, 13, 14, 15, 16, 17, + 18, -1, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, - 74, 41, 40, 40, 0, 43, 0, 81, 78, 10, - 11, 12, 13, 14, 15, 16, 43, 91, 92, 20, - 21, 22, 23, 24, 25, 11, 26, 27, 28, 29, - 30, 31, 32, 33, 34, 35, 36, 37, 13, -1, - -1, 41 + 3, 4, -1, -1, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, -1, -1, -1, -1, + -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, -1, -1, -1, + 41, 10, 11, 12, 13, 14, 15, 16, -1, -1, + -1, 20, 21, 22, 23, 24, 25 }; /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ -#line 3 "/usr/lib/bison.simple" +#line 3 "/usr/local/share/bison.simple" /* Skeleton output parser for bison, - Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman + Copyright (C) 1984, 1989, 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 1, or (at your option) + 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, @@ -302,6 +328,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ #ifndef alloca #ifdef __GNUC__ @@ -375,10 +405,18 @@ #ifdef YYPURE #ifdef YYLSP_NEEDED +#ifdef YYLEX_PARAM +#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) +#else #define YYLEX yylex(&yylval, &yylloc) +#endif +#else /* not YYLSP_NEEDED */ +#ifdef YYLEX_PARAM +#define YYLEX yylex(&yylval, YYLEX_PARAM) #else #define YYLEX yylex(&yylval) #endif +#endif /* not YYLSP_NEEDED */ #endif /* If nonreentrant, generate the variables here */ @@ -426,14 +464,14 @@ #endif #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ -#define __yy_bcopy(FROM,TO,COUNT) __builtin_memcpy(TO,FROM,COUNT) +#define __yy_memcpy(FROM,TO,COUNT) __builtin_memcpy(TO,FROM,COUNT) #else /* not GNU C or C++ */ #ifndef __cplusplus /* This is the most reliable way to avoid incompatibilities in available built-in functions on various systems. */ static void -__yy_bcopy (from, to, count) +__yy_memcpy (from, to, count) char *from; char *to; int count; @@ -451,7 +489,7 @@ /* This is the most reliable way to avoid incompatibilities in available built-in functions on various systems. */ static void -__yy_bcopy (char *from, char *to, int count) +__yy_memcpy (char *from, char *to, int count) { register char *f = from; register char *t = to; @@ -464,9 +502,24 @@ #endif #endif -#line 184 "/usr/lib/bison.simple" +#line 192 "/usr/local/share/bison.simple" + +/* The user can define YYPARSE_PARAM as the name of an argument to be passed + into yyparse. The argument should have type void *. + It should actually point to an object. + Grammar actions can access the variable by casting it + to the proper pointer type. */ + +#ifdef YYPARSE_PARAM +#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; +#else +#define YYPARSE_PARAM +#define YYPARSE_PARAM_DECL +#endif + int -yyparse() +yyparse(YYPARSE_PARAM) + YYPARSE_PARAM_DECL { register int yystate; register int yyn; @@ -582,12 +635,12 @@ if (yystacksize > YYMAXDEPTH) yystacksize = YYMAXDEPTH; yyss = (short *) alloca (yystacksize * sizeof (*yyssp)); - __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp)); + __yy_memcpy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp)); yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp)); - __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp)); + __yy_memcpy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp)); #ifdef YYLSP_NEEDED yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp)); - __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp)); + __yy_memcpy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp)); #endif #endif /* no yyoverflow */ @@ -747,102 +800,196 @@ switch (yyn) { -case 1: -#line 40 "parsetime.y" +case 2: +#line 44 "parsetime.y" { time_only = 1; ; break;} -case 20: -#line 68 "parsetime.y" +case 10: +#line 59 "parsetime.y" +{ + add_date(1, DAY); + ; + break;} +case 21: +#line 76 "parsetime.y" { exectm.tm_hour = 12; exectm.tm_min = 0; ; break;} -case 21: -#line 73 "parsetime.y" +case 22: +#line 81 "parsetime.y" { exectm.tm_hour = 0; exectm.tm_min = 0; add_date(1, DAY); ; break;} -case 22: -#line 79 "parsetime.y" +case 23: +#line 87 "parsetime.y" { exectm.tm_hour = 16; exectm.tm_min = 0; ; break;} -case 25: -#line 88 "parsetime.y" +case 27: +#line 97 "parsetime.y" { add_date ((7 + yyvsp[0].intval - exectm.tm_wday) %7 + 1, DAY); ; break;} -case 27: -#line 93 "parsetime.y" +case 29: +#line 102 "parsetime.y" { add_date(1, DAY); ; break;} -case 34: -#line 105 "parsetime.y" +case 36: +#line 112 "parsetime.y" +{ + /* Ok, this is a kluge. I hate design errors... -Joey */ + char shallot[5]; + char *onion; + + onion=yyvsp[0].charval; + memset (shallot, 0, sizeof (shallot)); + strncpy (shallot,onion,2); + sscanf(shallot, "%d", &exectm.tm_mon); + + if (exectm.tm_mon < 1 || exectm.tm_mon > 12) { + yyerror("Error in month number"); + YYERROR; + } + exectm.tm_mon--; + + onion+=2; + memset (shallot, 0, sizeof (shallot)); + strncpy (shallot,onion,2); + sscanf(shallot, "%d", &exectm.tm_mday); + if (exectm.tm_mday < 0 || exectm.tm_mday > 31) + { + yyerror("Error in day of month"); + YYERROR; + } + + if (strlen(yyvsp[0].charval) > 4) { + onion+=2; + memset (shallot, 0, sizeof (shallot)); + strncpy (shallot,onion,4); + if ( sscanf(shallot, "%d", &exectm.tm_year) != 1) { + yyerror("Error in year"); + YYERROR; + } + if (exectm.tm_year < 70) { + exectm.tm_year += 100; + } + else if (exectm.tm_year > 1900) { + exectm.tm_year -= 1900; + } + } + + free (yyvsp[0].charval); + ; + break;} +case 39: +#line 162 "parsetime.y" { add_date(yyvsp[-1].intval, yyvsp[0].intval); ; break;} -case 35: -#line 109 "parsetime.y" +case 40: +#line 166 "parsetime.y" { add_date(1, yyvsp[0].intval); ; break;} -case 36: -#line 113 "parsetime.y" +case 41: +#line 170 "parsetime.y" { add_date ((6 + yyvsp[0].intval - exectm.tm_wday) %7 +1, DAY); ; break;} -case 37: -#line 119 "parsetime.y" +case 42: +#line 176 "parsetime.y" { add_date(-yyvsp[-1].intval, yyvsp[0].intval); ; break;} -case 38: -#line 124 "parsetime.y" +case 43: +#line 181 "parsetime.y" { yyval.intval = MINUTE ; ; break;} -case 39: -#line 125 "parsetime.y" +case 44: +#line 182 "parsetime.y" { yyval.intval = HOUR ; ; break;} -case 40: -#line 126 "parsetime.y" +case 45: +#line 183 "parsetime.y" { yyval.intval = DAY ; ; break;} -case 41: -#line 127 "parsetime.y" +case 46: +#line 184 "parsetime.y" { yyval.intval = WEEK ; ; break;} -case 42: -#line 128 "parsetime.y" +case 47: +#line 185 "parsetime.y" { yyval.intval = MONTH ; ; break;} -case 43: -#line 129 "parsetime.y" +case 48: +#line 186 "parsetime.y" { yyval.intval = YEAR ; ; break;} -case 44: -#line 133 "parsetime.y" +case 49: +#line 190 "parsetime.y" { - exectm.tm_min = -1; - exectm.tm_hour = -1; if (strlen(yyvsp[0].charval) == 4) { + exectm.tm_min = -1; + exectm.tm_hour = -1; sscanf(yyvsp[0].charval, "%2d %2d", &exectm.tm_hour, &exectm.tm_min); + } else if (strlen(yyvsp[0].charval) == 6 || strlen(yyvsp[0].charval) == 8) { + /* Ok, this is a kluge. I hate design errors... -Joey */ + char shallot[5]; + char *onion; + + onion=yyvsp[0].charval; + memset (shallot, 0, sizeof (shallot)); + strncpy (shallot,onion,2); + sscanf(shallot, "%d", &exectm.tm_mon); + + if (exectm.tm_mon < 1 || exectm.tm_mon > 12) { + yyerror("Error in month number"); + YYERROR; + } + exectm.tm_mon--; + + onion+=2; + memset (shallot, 0, sizeof (shallot)); + strncpy (shallot,onion,2); + sscanf(shallot, "%d", &exectm.tm_mday); + if (exectm.tm_mday < 0 || exectm.tm_mday > 31) + { + yyerror("Error in day of month"); + YYERROR; + } + + onion+=2; + memset (shallot, 0, sizeof (shallot)); + strncpy (shallot,onion,4); + if ( sscanf(shallot, "%d", &exectm.tm_year) != 1) { + yyerror("Error in year"); + YYERROR; + } + if (exectm.tm_year < 70) { + exectm.tm_year += 100; + } + else if (exectm.tm_year > 1900) { + exectm.tm_year -= 1900; + } + + free (yyvsp[0].charval); } else { sscanf(yyvsp[0].charval, "%d", &exectm.tm_hour); @@ -860,8 +1007,8 @@ } ; break;} -case 45: -#line 158 "parsetime.y" +case 50: +#line 256 "parsetime.y" { if (strcasecmp(yyvsp[0].charval,"utc") == 0) { isgmt = 1; @@ -873,8 +1020,8 @@ free(yyvsp[0].charval); ; break;} -case 47: -#line 174 "parsetime.y" +case 52: +#line 272 "parsetime.y" { if (sscanf(yyvsp[0].charval, "%d", &exectm.tm_min) != 1) { yyerror("Error in minute"); @@ -883,8 +1030,20 @@ free(yyvsp[0].charval); ; break;} -case 49: -#line 185 "parsetime.y" +case 53: +#line 282 "parsetime.y" +{ + if (exectm.tm_hour > 12) { + yyerror("Hour too large for AM"); + YYERROR; + } + else if (exectm.tm_hour == 12) { + exectm.tm_hour = 0; + } + ; + break;} +case 54: +#line 292 "parsetime.y" { if (exectm.tm_hour > 12) { yyerror("Hour too large for PM"); @@ -895,56 +1054,56 @@ } ; break;} -case 50: -#line 197 "parsetime.y" +case 55: +#line 304 "parsetime.y" { exectm.tm_mon = 0; ; break;} -case 51: -#line 198 "parsetime.y" +case 56: +#line 305 "parsetime.y" { exectm.tm_mon = 1; ; break;} -case 52: -#line 199 "parsetime.y" +case 57: +#line 306 "parsetime.y" { exectm.tm_mon = 2; ; break;} -case 53: -#line 200 "parsetime.y" +case 58: +#line 307 "parsetime.y" { exectm.tm_mon = 3; ; break;} -case 54: -#line 201 "parsetime.y" +case 59: +#line 308 "parsetime.y" { exectm.tm_mon = 4; ; break;} -case 55: -#line 202 "parsetime.y" +case 60: +#line 309 "parsetime.y" { exectm.tm_mon = 5; ; break;} -case 56: -#line 203 "parsetime.y" +case 61: +#line 310 "parsetime.y" { exectm.tm_mon = 6; ; break;} -case 57: -#line 204 "parsetime.y" +case 62: +#line 311 "parsetime.y" { exectm.tm_mon = 7; ; break;} -case 58: -#line 205 "parsetime.y" +case 63: +#line 312 "parsetime.y" { exectm.tm_mon = 8; ; break;} -case 59: -#line 206 "parsetime.y" +case 64: +#line 313 "parsetime.y" { exectm.tm_mon = 9; ; break;} -case 60: -#line 207 "parsetime.y" +case 65: +#line 314 "parsetime.y" { exectm.tm_mon =10; ; break;} -case 61: -#line 208 "parsetime.y" +case 66: +#line 315 "parsetime.y" { exectm.tm_mon =11; ; break;} -case 62: -#line 212 "parsetime.y" +case 67: +#line 319 "parsetime.y" { { int mnum = -1; @@ -959,8 +1118,8 @@ } ; break;} -case 63: -#line 226 "parsetime.y" +case 68: +#line 333 "parsetime.y" { exectm.tm_mday = -1; sscanf(yyvsp[0].charval, "%d", &exectm.tm_mday); @@ -972,8 +1131,8 @@ free(yyvsp[0].charval); ; break;} -case 64: -#line 239 "parsetime.y" +case 69: +#line 346 "parsetime.y" { { int ynum; @@ -994,36 +1153,36 @@ } ; break;} -case 65: -#line 261 "parsetime.y" +case 70: +#line 368 "parsetime.y" { yyval.intval = 0; ; break;} -case 66: -#line 262 "parsetime.y" +case 71: +#line 369 "parsetime.y" { yyval.intval = 1; ; break;} -case 67: -#line 263 "parsetime.y" +case 72: +#line 370 "parsetime.y" { yyval.intval = 2; ; break;} -case 68: -#line 264 "parsetime.y" +case 73: +#line 371 "parsetime.y" { yyval.intval = 3; ; break;} -case 69: -#line 265 "parsetime.y" +case 74: +#line 372 "parsetime.y" { yyval.intval = 4; ; break;} -case 70: -#line 266 "parsetime.y" +case 75: +#line 373 "parsetime.y" { yyval.intval = 5; ; break;} -case 71: -#line 267 "parsetime.y" +case 76: +#line 374 "parsetime.y" { yyval.intval = 6; ; break;} -case 72: -#line 271 "parsetime.y" +case 77: +#line 378 "parsetime.y" { if (sscanf(yyvsp[0].charval, "%d", &yyval.intval) != 1) { yyerror("Unknown increment"); @@ -1034,7 +1193,7 @@ break;} } /* the action file gets copied in in place of this dollarsign */ -#line 465 "/usr/lib/bison.simple" +#line 487 "/usr/local/share/bison.simple" yyvsp -= yylen; yyssp -= yylen; @@ -1230,7 +1389,7 @@ yystate = yyn; goto yynewstate; } -#line 287 "parsetime.y" +#line 394 "parsetime.y" @@ -1266,6 +1425,24 @@ } #ifdef TEST_PARSER +/* + +Here are some lines to test: + +./parsetest 7AM Mar 24 2000 +./parsetest 7AM Mar 24 00 +./parsetest 7AM 032400 +./parsetest 7AM 03/24/00 +./parsetest 7AM 24.03.00 +./parsetest 7AM Mar 24 + +./parsetest 03242000 +./parsetest noon 03242000 +./parsetest 5:30 +./parsetest 4pm + 3 days +./parsetest 10am Jul 31 + + */ int main(int argc, char **argv) {