From 5706670029c62be05b709748fe902bdd1973cd97 Mon Sep 17 00:00:00 2001 From: Arun Thomas Date: Wed, 12 May 2010 16:28:54 +0000 Subject: [PATCH] Convert boot/ and commands/ over to bsdmake --- Makefile | 3 + boot/Makefile | 153 +- commands/{scripts => DESCRIBE}/DESCRIBE.sh | 0 commands/DESCRIBE/Makefile | 4 + commands/{scripts => M}/M.sh | 0 commands/M/Makefile | 7 + commands/{scripts => MAKEDEV}/MAKEDEV.sh | 0 commands/MAKEDEV/Makefile | 4 + commands/Makefile | 65 +- commands/Makefile.inc | 2 + commands/aal/Makefile | 60 +- commands/aal/build | 3 - commands/acd/Makefile | 13 + commands/{i386 => acd}/acd.c | 0 commands/{i386 => acd}/acd.descr | 0 commands/add_route/Makefile | 6 + commands/{simple => add_route}/add_route.c | 0 commands/adduser/Makefile | 4 + commands/{scripts => adduser}/adduser.sh | 0 commands/advent/Makefile | 67 +- commands/advent/build | 3 - commands/arp/Makefile | 5 + commands/{simple => arp}/arp.c | 0 commands/ash/Makefile | 146 +- commands/ash/alias.c | 1 - commands/ash/arith.h | 39 - commands/ash/arith.y | 10 +- commands/ash/arith_lex.l | 7 +- commands/ash/expand.h | 7 + commands/asmconv/Makefile | 8 + commands/{i386 => }/asmconv/asm86.c | 0 commands/{i386 => }/asmconv/asm86.h | 0 commands/{i386 => }/asmconv/asmconv.c | 0 commands/{i386 => }/asmconv/asmconv.h | 0 commands/{i386 => }/asmconv/emit_ack.c | 0 commands/{i386 => }/asmconv/emit_gnu.c | 0 commands/{i386 => }/asmconv/languages.h | 0 commands/{i386 => }/asmconv/parse_ack.c | 0 commands/{i386 => }/asmconv/parse_bas.c | 0 commands/{i386 => }/asmconv/parse_gnu.c | 0 commands/{i386 => }/asmconv/syntax.ack | 0 commands/{i386 => }/asmconv/token.h | 0 commands/{i386 => }/asmconv/tokenize.c | 0 commands/at/Makefile | 5 + commands/{simple => at}/at.c | 0 commands/atnormalize/Makefile | 4 + commands/{ibm => atnormalize}/atnormalize.c | 0 commands/autil/Makefile | 30 +- commands/autil/build | 3 - commands/autopart/Makefile | 4 + commands/{ibm => autopart}/autopart.c | 0 commands/awk/Makefile | 97 +- commands/awk/Makefile.orig | 94 + commands/awk/b.c | 2 +- commands/awk/buildwin.bat | 12 - commands/awk/lex.c | 2 +- commands/awk/lib.c | 2 +- commands/awk/main.c | 2 +- commands/awk/makefile.win | 9 - commands/awk/maketab.c | 2 +- commands/awk/missing95.c | 12 - commands/awk/parse.c | 2 +- commands/awk/proctab.c | 207 + commands/awk/run.c | 2 +- commands/awk/tran.c | 2 +- commands/awk/vcvars32.bat | 33 - commands/awk/ytabc.bak | 3707 ----------------- commands/awk/ytabh.bak | 253 -- commands/backup/Makefile | 6 + commands/{simple => backup}/backup.c | 0 commands/badblocks/Makefile | 5 + commands/{simple => badblocks}/badblocks.c | 6 +- commands/banner/Makefile | 4 + commands/{simple => banner}/banner.c | 0 commands/basename/Makefile | 4 + commands/{simple => basename}/basename.c | 0 commands/bigmake/Makefile | 4 + commands/{scripts => bigmake}/bigmake.sh | 0 commands/binpackage/Makefile | 4 + .../{scripts => binpackage}/binpackage.sh | 0 commands/binpackages/Makefile | 4 + .../{scripts => binpackages}/binpackages.sh | 0 commands/binsizes/Makefile | 4 + commands/{scripts => binsizes}/binsizes.sh | 0 commands/byacc/MANIFEST | 33 - commands/byacc/Makefile | 86 - commands/byacc/NOTES | 9 - commands/byacc/NO_WARRANTY | 3 - commands/byacc/build | 3 - commands/byacc/main.c | 378 -- commands/byacc/symtab.c | 119 - commands/byacc/warshall.c | 82 - commands/bzip2-1.0.3/README.MINIX | 172 - commands/bzip2-1.0.3/build | 6 - commands/bzip2-1.0.3/bzdiff.1 | 1 - commands/bzip2-1.0.3/bzgrep.1 | 1 - commands/bzip2-1.0.3/bzip2.1 | 1 - commands/bzip2-1.0.3/bzmore.1 | 1 - commands/{bzip2-1.0.3 => bzip2}/CHANGES | 0 commands/{bzip2-1.0.3 => bzip2}/LICENSE | 0 commands/bzip2/Makefile | 14 + .../{bzip2-1.0.3 => bzip2}/Makefile-libbz2_so | 0 .../Makefile => bzip2/Makefile.orig} | 0 .../README.ORIGINAL => bzip2/README} | 0 .../README.COMPILATION.PROBLEMS | 0 .../{bzip2-1.0.3 => bzip2}/README.XML.STUFF | 0 commands/{bzip2-1.0.3 => bzip2}/Y2K_INFO | 0 commands/{bzip2-1.0.3 => bzip2}/blocksort.c | 0 commands/{bzip2-1.0.3 => bzip2}/bz-common.xsl | 0 commands/{bzip2-1.0.3 => bzip2}/bz-fo.xsl | 0 commands/{bzip2-1.0.3 => bzip2}/bz-html.xsl | 0 commands/{bzip2-1.0.3 => bzip2}/bzdiff | 0 {man/man1 => commands/bzip2}/bzdiff.1 | 0 commands/{bzip2-1.0.3 => bzip2}/bzgrep | 0 {man/man1 => commands/bzip2}/bzgrep.1 | 0 commands/{bzip2-1.0.3 => bzip2}/bzip.css | 0 {man/man1 => commands/bzip2}/bzip2.1 | 0 .../bzip2.1.preformatted | 0 commands/{bzip2-1.0.3 => bzip2}/bzip2.c | 0 commands/{bzip2-1.0.3 => bzip2}/bzip2.txt | 0 .../{bzip2-1.0.3 => bzip2}/bzip2recover.c | 0 commands/{bzip2-1.0.3 => bzip2}/bzlib.c | 0 commands/{bzip2-1.0.3 => bzip2}/bzlib.h | 0 .../{bzip2-1.0.3 => bzip2}/bzlib_private.h | 0 commands/{bzip2-1.0.3 => bzip2}/bzmore | 0 {man/man1 => commands/bzip2}/bzmore.1 | 0 commands/{bzip2-1.0.3 => bzip2}/compress.c | 0 commands/{bzip2-1.0.3 => bzip2}/crctable.c | 0 commands/{bzip2-1.0.3 => bzip2}/decompress.c | 0 commands/{bzip2-1.0.3 => bzip2}/dlltest.c | 0 commands/{bzip2-1.0.3 => bzip2}/dlltest.dsp | 0 commands/{bzip2-1.0.3 => bzip2}/entities.xml | 0 commands/{bzip2-1.0.3 => bzip2}/format.pl | 0 commands/{bzip2-1.0.3 => bzip2}/huffman.c | 0 commands/{bzip2-1.0.3 => bzip2}/libbz2.def | 0 commands/{bzip2-1.0.3 => bzip2}/libbz2.dsp | 0 commands/{bzip2-1.0.3 => bzip2}/makefile.msc | 0 commands/{bzip2-1.0.3 => bzip2}/mk251.c | 0 commands/{bzip2-1.0.3 => bzip2}/randtable.c | 0 commands/{bzip2-1.0.3 => bzip2}/sample1.bz2 | Bin commands/{bzip2-1.0.3 => bzip2}/sample1.ref | Bin commands/{bzip2-1.0.3 => bzip2}/sample2.bz2 | Bin commands/{bzip2-1.0.3 => bzip2}/sample2.ref | Bin commands/{bzip2-1.0.3 => bzip2}/sample3.bz2 | Bin commands/{bzip2-1.0.3 => bzip2}/sample3.ref | 0 commands/{bzip2-1.0.3 => bzip2}/spewG.c | 0 commands/{bzip2-1.0.3 => bzip2}/unzcrash.c | 0 commands/{bzip2-1.0.3 => bzip2}/words0 | 0 commands/{bzip2-1.0.3 => bzip2}/words1 | 0 commands/{bzip2-1.0.3 => bzip2}/words2 | 0 commands/{bzip2-1.0.3 => bzip2}/words3 | 0 commands/{bzip2-1.0.3 => bzip2}/xmlproc.sh | 0 commands/bzip2recover/Makefile | 11 + commands/cal/Makefile | 4 + commands/{simple => cal}/cal.c | 0 commands/calendar/Makefile | 4 + commands/{simple => calendar}/calendar.c | 0 commands/cat/Makefile | 5 + commands/{simple => cat}/cat.c | 0 commands/cawf/Makefile | 79 +- commands/cawf/build | 3 - commands/cawf/proto.h | 1 - commands/cd/Makefile | 18 + commands/{scripts => cd}/cd.sh | 0 commands/cdiff/Makefile | 4 + commands/{simple => cdiff}/cdiff.c | 0 commands/cdprobe/Makefile | 5 + commands/{simple => cdprobe}/cdprobe.c | 2 +- commands/cgrep/Makefile | 4 + commands/{simple => cgrep}/cgrep.c | 0 commands/checkhier/Makefile | 4 + commands/{scripts => checkhier}/checkhier.sh | 0 commands/chmem/Makefile | 4 + commands/{simple => chmem}/chmem.c | 0 commands/chmod/Makefile | 4 + commands/{simple => chmod}/chmod.c | 0 commands/chown/Makefile | 6 + commands/{simple => chown}/chown.c | 0 commands/chroot/Makefile | 5 + commands/{simple => chroot}/chroot.c | 0 commands/ci/Makefile | 4 + commands/{simple => ci}/ci.c | 0 commands/cksum/Makefile | 4 + commands/{simple => cksum}/cksum.c | 0 commands/cleantmp/Makefile | 4 + commands/{simple => cleantmp}/cleantmp.c | 0 commands/clear/Makefile | 6 + commands/{scripts => clear}/clear.sh | 0 commands/cmp/Makefile | 4 + commands/{simple => cmp}/cmp.c | 0 commands/co/Makefile | 4 + commands/{simple => co}/co.c | 0 commands/comm/Makefile | 4 + commands/{simple => comm}/comm.c | 0 commands/compress/Makefile | 7 + commands/{simple => compress}/compress.c | 0 commands/cp/Makefile | 11 + commands/{simple => cp}/cp.c | 0 commands/crc/Makefile | 4 + commands/{simple => crc}/crc.c | 0 commands/cron/Makefile | 35 +- commands/cron/build | 3 - commands/crontab/Makefile | 13 + commands/{cron => crontab}/crontab.c | 0 commands/cut/Makefile | 4 + commands/{simple => cut}/cut.c | 0 commands/datasizes/Makefile | 4 + commands/{scripts => datasizes}/datasizes.sh | 0 commands/date/Makefile | 11 + commands/dd/Makefile | 4 + commands/{simple => dd}/dd.c | 0 commands/de/Makefile | 25 +- commands/de/build | 3 - commands/de/de.c | 6 +- commands/de/de_diskio.c | 8 +- commands/de/de_recover.c | 6 +- commands/de/de_stdin.c | 4 +- commands/de/de_stdout.c | 6 +- commands/decomp16/Makefile | 4 + commands/{simple => decomp16}/decomp16.c | 0 commands/dev2name/Makefile | 5 + commands/{simple => dev2name}/dev2name.c | 0 commands/devsize/Makefile | 4 + commands/{simple => devsize}/devsize.c | 0 commands/df/Makefile | 6 + commands/{simple => df}/df.c | 0 commands/dhcpd/Makefile | 26 +- commands/dhcpd/build | 3 - commands/dhrystone/Makefile | 4 + commands/{simple => dhrystone}/dhrystone.c | 0 commands/diff/Makefile | 4 + commands/{simple => diff}/diff.c | 0 commands/dirname/Makefile | 4 + commands/{simple => dirname}/dirname.c | 0 commands/dis88/Makefile | 28 +- commands/dis88/build | 3 - commands/dosread/Makefile | 7 + commands/{ibm => dosread}/dosread.c | 0 commands/du/Makefile | 4 + commands/{simple => du}/du.c | 0 commands/dumpcore/Makefile | 5 + commands/{simple => dumpcore}/dumpcore.c | 2 +- commands/easypack/Makefile | 4 + commands/{scripts => easypack}/easypack.sh | 0 commands/ed/Makefile | 4 + commands/{simple => ed}/ed.c | 0 commands/eject/Makefile | 4 + commands/{simple => eject}/eject.c | 0 commands/elle/Makefile | 52 +- commands/elle/build | 3 - commands/elvis/Makefile | 91 +- commands/elvis/build | 2 - commands/elvis/ctags.c | 2 +- commands/elvis/ref.c | 2 +- commands/env/Makefile | 6 + commands/{simple => env}/env.c | 0 commands/expand/Makefile | 4 + commands/{simple => expand}/expand.c | 0 commands/factor/Makefile | 4 + commands/{simple => factor}/factor.c | 0 commands/fdisk/Makefile | 4 + commands/{ibm => fdisk}/fdisk.c | 0 commands/fgrep/Makefile | 4 + commands/{simple => fgrep}/fgrep.c | 0 commands/file/Makefile | 4 + commands/{simple => file}/file.c | 0 commands/find/Makefile | 4 + commands/{simple => find}/find.c | 0 commands/finger/Makefile | 4 + commands/{simple => finger}/finger.c | 0 commands/fingerd/Makefile | 5 + .../in.fingerd.c => fingerd/fingerd.c} | 0 commands/fix/Makefile | 4 + commands/{simple => fix}/fix.c | 0 commands/flex-2.5.4/.descr | 1 - commands/flex-2.5.4/INSTALL | 117 - commands/flex-2.5.4/MISC/Amiga/README.amiga | 72 - commands/flex-2.5.4/MISC/Amiga/SMakefile | 195 - commands/flex-2.5.4/MISC/Amiga/config.h | 25 - commands/flex-2.5.4/MISC/Amiga/libmain.ch | 8 - commands/flex-2.5.4/MISC/Amiga/libyywrap.ch | 8 - commands/flex-2.5.4/MISC/Amiga/parse.ych | 8 - commands/flex-2.5.4/MISC/Atari/Atari.patches | 911 ---- .../flex-2.5.4/MISC/Borland.old/Borland-2.4 | 419 -- commands/flex-2.5.4/MISC/Borland.old/Turbo-C | 179 - commands/flex-2.5.4/MISC/Borland/Makefile | 163 - commands/flex-2.5.4/MISC/Borland/NOTES | 66 - commands/flex-2.5.4/MISC/Borland/config.h | 29 - commands/flex-2.5.4/MISC/EBCDIC | 48 - commands/flex-2.5.4/MISC/MSDOS/MSC70.make | 115 - commands/flex-2.5.4/MISC/MSDOS/configur.bat | 6 - commands/flex-2.5.4/MISC/MSDOS/djgpp.sed | 12 - commands/flex-2.5.4/MISC/MVS/MVS.mail | 56 - commands/flex-2.5.4/MISC/MVS/MVS.todo | 23 - commands/flex-2.5.4/MISC/MVS/MVS.uudecode | 341 -- commands/flex-2.5.4/MISC/MVS/README | 44 - commands/flex-2.5.4/MISC/MVS/diffs | 854 ---- commands/flex-2.5.4/MISC/MVS/fixit.l | 138 - commands/flex-2.5.4/MISC/MVS/initscan-mvs.c | 2672 ------------ commands/flex-2.5.4/MISC/MVS/unfixit.l | 141 - .../flex-2.5.4/MISC/Macintosh/THINK_C_notes | 100 - commands/flex-2.5.4/MISC/Macintosh/alloca.c | 195 - commands/flex-2.5.4/MISC/Macintosh/alloca.h | 10 - commands/flex-2.5.4/MISC/Macintosh/xmalloc.c | 69 - commands/flex-2.5.4/MISC/NT/Makefile | 103 - commands/flex-2.5.4/MISC/NeXT | 34 - commands/flex-2.5.4/MISC/OS2/Makefile.os2 | 72 - commands/flex-2.5.4/MISC/OS2/config.h | 28 - commands/flex-2.5.4/MISC/README | 76 - commands/flex-2.5.4/MISC/VMS/README.VMS | 83 - commands/flex-2.5.4/MISC/VMS/build.com | 155 - commands/flex-2.5.4/MISC/VMS/descrip.mms | 311 -- commands/flex-2.5.4/MISC/VMS/mkskel.tpu | 45 - commands/flex-2.5.4/MISC/VMS/vms-code.c | 152 - commands/flex-2.5.4/MISC/VMS/vms-conf.h | 32 - commands/flex-2.5.4/MISC/alloca.c | 484 --- commands/flex-2.5.4/MISC/debflex.awk | 119 - commands/flex-2.5.4/MISC/fastwc/README | 56 - commands/flex-2.5.4/MISC/fastwc/mywc.c | 26 - commands/flex-2.5.4/MISC/fastwc/wc1.l | 18 - commands/flex-2.5.4/MISC/fastwc/wc2.l | 20 - commands/flex-2.5.4/MISC/fastwc/wc3.l | 24 - commands/flex-2.5.4/MISC/fastwc/wc4.l | 27 - commands/flex-2.5.4/MISC/fastwc/wc5.l | 24 - commands/flex-2.5.4/MISC/flex.man | 3696 ---------------- commands/flex-2.5.4/MISC/parse.c | 1452 ------- commands/flex-2.5.4/MISC/parse.h | 24 - commands/flex-2.5.4/MISC/testxxLexer.l | 58 - commands/flex-2.5.4/MISC/texinfo/flex.info | 2951 ------------- commands/flex-2.5.4/MISC/texinfo/flex.texi | 3448 --------------- commands/flex-2.5.4/Makefile.in | 264 -- commands/flex-2.5.4/README | 60 - commands/flex-2.5.4/build | 24 - commands/flex-2.5.4/conf.in | 25 - commands/flex-2.5.4/configure | 1633 -------- commands/flex-2.5.4/configure.in | 29 - commands/flex-2.5.4/configure.minix | 2 - commands/flex-2.5.4/install.sh | 119 - commands/flex-2.5.4/mkinstalldirs | 35 - commands/flex-2.5.4/skel.c | 1548 ------- commands/fold/Makefile | 4 + commands/{simple => fold}/fold.c | 0 commands/format/Makefile | 5 + commands/{ibm => format}/format.c | 0 commands/fortune/Makefile | 4 + commands/{simple => fortune}/fortune.c | 0 commands/fsck/Makefile | 6 + commands/{simple => fsck}/fsck.c | 8 +- commands/fsck1/Makefile | 5 + commands/{simple => fsck1}/fsck1.c | 8 +- commands/ftp101/Makefile | 37 +- commands/ftpd200/Makefile | 42 +- commands/ftpd200/build | 3 - commands/gas2ack/Makefile | 8 + commands/{i386 => }/gas2ack/asm86.c | 0 commands/{i386 => }/gas2ack/asm86.h | 0 commands/{i386 => }/gas2ack/asmconv.h | 0 commands/{i386 => }/gas2ack/emit_ack.c | 0 commands/{i386 => }/gas2ack/gas2ack.c | 0 commands/{i386 => }/gas2ack/globals.c | 0 commands/{i386 => }/gas2ack/globals.h | 0 commands/{i386 => }/gas2ack/languages.h | 0 commands/{i386 => }/gas2ack/parse_gnu.c | 0 commands/{i386 => }/gas2ack/token.h | 0 commands/{i386 => }/gas2ack/tokenize.c | 0 commands/getty/Makefile | 5 + commands/{simple => getty}/getty.c | 0 commands/gomoku/Makefile | 7 + commands/{simple => gomoku}/gomoku.c | 0 commands/grep/Makefile | 6 + commands/{simple => grep}/grep.c | 0 commands/head/Makefile | 4 + commands/{simple => head}/head.c | 0 commands/host/Makefile | 4 + commands/{simple => host}/host.c | 0 commands/hostaddr/Makefile | 5 + commands/{simple => hostaddr}/hostaddr.c | 0 commands/i386/Makefile | 31 - commands/i386/asmconv/Makefile | 32 - commands/i386/asmconv/build | 3 - commands/i386/build | 3 - commands/i386/gas2ack/Makefile | 29 - commands/ibm/Makefile | 168 - commands/ibm/build | 3 - commands/id/Makefile | 4 + commands/{simple => id}/id.c | 0 commands/ifconfig/Makefile | 5 + commands/{simple => ifconfig}/ifconfig.c | 0 commands/ifdef/Makefile | 4 + commands/{simple => ifdef}/ifdef.c | 0 commands/indent/Makefile | 24 +- commands/indent/build | 3 - commands/install/Makefile | 9 + commands/{simple => install}/install.c | 0 commands/intr/Makefile | 5 + commands/{simple => intr}/intr.c | 0 commands/ipcrm/Makefile | 4 + commands/{simple => ipcrm}/ipcrm.c | 0 commands/ipcs/Makefile | 4 + commands/{simple => ipcs}/ipcs.c | 0 commands/irdpd/Makefile | 4 + commands/{simple => irdpd}/irdpd.c | 0 commands/isoread/Makefile | 7 + commands/{simple => isoread}/isoread.c | 0 commands/join/Makefile | 4 + commands/{simple => join}/join.c | 0 commands/kill/Makefile | 4 + commands/{simple => kill}/kill.c | 0 commands/last/Makefile | 6 + commands/{simple => last}/last.c | 0 commands/leave/Makefile | 4 + commands/{simple => leave}/leave.c | 0 commands/{flex-2.5.4 => lex}/COPYING | 0 commands/{flex-2.5.4 => lex}/FlexLexer.h | 0 commands/lex/Makefile | 44 + commands/{flex-2.5.4 => lex}/NEWS | 0 commands/{flex-2.5.4 => lex}/ccl.c | 0 commands/{flex-2.5.4/MISC/NT => lex}/config.h | 17 +- commands/{flex-2.5.4 => lex}/dfa.c | 0 commands/{flex-2.5.4 => lex}/ecs.c | 0 commands/{flex-2.5.4 => lex}/flex.1 | 0 commands/{flex-2.5.4 => lex}/flex.skl | 0 commands/{flex-2.5.4 => lex}/flexdef.h | 0 commands/{flex-2.5.4 => lex}/gen.c | 0 commands/{flex-2.5.4 => lex}/initscan.c | 0 commands/{flex-2.5.4 => lex}/libmain.c | 0 commands/{flex-2.5.4 => lex}/libyywrap.c | 0 commands/{flex-2.5.4 => lex}/main.c | 0 commands/{flex-2.5.4 => lex}/misc.c | 0 commands/{flex-2.5.4 => lex}/mkskel.sh | 0 commands/{flex-2.5.4 => lex}/nfa.c | 0 commands/{flex-2.5.4 => lex}/parse.y | 0 commands/{flex-2.5.4 => lex}/scan.l | 0 commands/{flex-2.5.4 => lex}/sym.c | 0 commands/{flex-2.5.4 => lex}/tblcmp.c | 0 commands/{flex-2.5.4 => lex}/version.h | 0 commands/{flex-2.5.4 => lex}/yylex.c | 0 commands/life/Makefile | 7 + commands/{simple => life}/life.c | 0 commands/loadfont/Makefile | 4 + commands/{ibm => loadfont}/loadfont.c | 0 commands/loadkeys/Makefile | 5 + commands/{ibm => loadkeys}/loadkeys.c | 0 commands/loadramdisk/Makefile | 4 + .../{simple => loadramdisk}/loadramdisk.c | 0 commands/logger/Makefile | 4 + commands/{syslogd => logger}/logger.c | 0 commands/login/Makefile | 4 + commands/{simple => login}/login.c | 0 commands/look/Makefile | 4 + commands/{simple => look}/look.c | 0 commands/lp/Makefile | 4 + commands/{simple => lp}/lp.c | 0 commands/lpd/Makefile | 6 + commands/{simple => lpd}/lpd.c | 0 commands/ls/Makefile | 5 + commands/{simple => ls}/ls.c | 0 commands/lspci/Makefile | 4 + commands/{simple => lspci}/lspci.c | 0 commands/m4/Makefile | 23 +- commands/m4/build | 3 - commands/mail/Makefile | 5 + commands/{simple => mail}/mail.c | 0 commands/make/Makefile | 74 +- commands/make/unit-tests/Makefile | 2 +- commands/makewhatis/Makefile | 4 + .../{scripts => makewhatis}/makewhatis.sh | 0 commands/man/Makefile | 4 + commands/{simple => man}/man.c | 0 commands/mdb/Makefile | 116 +- commands/mdb/build | 3 - commands/mesg/Makefile | 4 + commands/{simple => mesg}/mesg.c | 0 commands/mined/Makefile | 25 +- commands/mined/build | 3 - commands/mixer/Makefile | 7 + commands/{ibm => mixer}/mixer.c | 0 commands/mkdep/Makefile | 4 + commands/{scripts => mkdep}/mkdep.sh | 0 commands/mkdir/Makefile | 4 + commands/{simple => mkdir}/mkdir.c | 0 commands/mkdist/Makefile | 4 + commands/{scripts => mkdist}/mkdist.sh | 0 commands/mkfifo/Makefile | 4 + commands/{simple => mkfifo}/mkfifo.c | 0 commands/mkfs/Makefile | 5 + commands/{simple => mkfs}/mkfs.c | 8 +- commands/mknod/Makefile | 4 + commands/{simple => mknod}/mknod.c | 0 commands/mkproto/Makefile | 4 + commands/{simple => mkproto}/mkproto.c | 0 commands/modem/Makefile | 4 + commands/{simple => modem}/modem.c | 0 commands/mount/Makefile | 7 + commands/{simple => mount}/mount.c | 2 +- commands/mt/Makefile | 4 + commands/{simple => mt}/mt.c | 0 commands/netconf/Makefile | 5 + commands/{scripts => netconf}/netconf.sh | 0 commands/newroot/Makefile | 4 + commands/{simple => newroot}/newroot.c | 0 commands/nice/Makefile | 4 + commands/{simple => nice}/nice.c | 0 commands/nm/Makefile | 4 + commands/{simple => nm}/nm.c | 0 commands/nohup/Makefile | 4 + commands/{simple => nohup}/nohup.c | 0 commands/nonamed/Makefile | 4 + commands/{simple => nonamed}/nonamed.c | 0 commands/od/Makefile | 4 + commands/{simple => od}/od.c | 0 commands/packit/Makefile | 4 + commands/{scripts => packit}/packit.sh | 0 commands/packman/Makefile | 4 + commands/{scripts => packman}/packman.sh | 0 commands/part/Makefile | 4 + commands/{ibm => part}/part.c | 0 commands/partition/Makefile | 4 + commands/{ibm => partition}/partition.c | 0 commands/passwd/Makefile | 8 + commands/{simple => passwd}/passwd.c | 0 commands/paste/Makefile | 4 + commands/{simple => paste}/paste.c | 0 commands/patch/Makefile | 30 +- commands/patch/build | 3 - commands/pax/Makefile | 3 +- commands/ping/Makefile | 5 + commands/{simple => ping}/ping.c | 0 commands/playwave/Makefile | 4 + commands/{ibm => playwave}/playwave.c | 0 commands/postinstall/Makefile | 4 + .../{scripts => postinstall}/postinstall.sh | 0 commands/postmort/Makefile | 5 + commands/{ibm => postmort}/postmort.c | 8 +- commands/poweroff/Makefile | 4 + commands/{scripts => poweroff}/poweroff.sh | 0 commands/pr/Makefile | 4 + commands/{simple => pr}/pr.c | 0 commands/pr_routes/Makefile | 5 + commands/{simple => pr_routes}/pr_routes.c | 0 commands/prep/Makefile | 4 + commands/{simple => prep}/prep.c | 0 commands/printf/Makefile | 4 + commands/{simple => printf}/printf.c | 0 commands/printroot/Makefile | 5 + commands/{simple => printroot}/printroot.c | 0 commands/profile/Makefile | 30 +- commands/profile/profile.c | 3 - commands/progressbar/Makefile | 4 + .../{simple => progressbar}/progressbar.c | 0 commands/proto/Makefile | 4 + commands/{simple => proto}/proto.c | 0 commands/ps/Makefile | 26 +- commands/ps/build | 3 - commands/ps/ps.c | 16 +- commands/pwd/Makefile | 5 + commands/{simple => pwd}/pwd.c | 0 commands/pwdauth/Makefile | 6 + commands/{simple => pwdauth}/pwdauth.c | 0 commands/ramdisk/Makefile | 4 + commands/{simple => ramdisk}/ramdisk.c | 0 commands/rarpd/Makefile | 4 + commands/{simple => rarpd}/rarpd.c | 0 commands/rawspeed/Makefile | 4 + commands/{simple => rawspeed}/rawspeed.c | 0 commands/rcp/Makefile | 4 + commands/{simple => rcp}/rcp.c | 0 commands/rdate/Makefile | 4 + commands/{simple => rdate}/rdate.c | 0 commands/readall/Makefile | 4 + commands/{simple => readall}/readall.c | 0 commands/readclock/Makefile | 5 + commands/{scripts => readclock}/readclock.sh | 0 commands/readfs/Makefile | 5 + commands/{simple => readfs}/readfs.c | 8 +- commands/reboot/Makefile | 47 +- commands/reboot/build | 3 - commands/recwave/Makefile | 4 + commands/{ibm => recwave}/recwave.c | 0 commands/remsync/Makefile | 4 + commands/{simple => remsync}/remsync.c | 0 commands/repartition/Makefile | 4 + commands/{ibm => repartition}/repartition.c | 0 commands/rev/Makefile | 4 + commands/{simple => rev}/rev.c | 0 commands/rget/Makefile | 6 + commands/{simple => rget}/rget.c | 0 commands/rlogin/Makefile | 4 + commands/{simple => rlogin}/rlogin.c | 0 commands/rlogind/Makefile | 25 +- commands/rlogind/build | 3 - commands/rmdir/Makefile | 4 + commands/{simple => rmdir}/rmdir.c | 0 commands/rotate/Makefile | 4 + commands/{scripts => rotate}/rotate.sh | 0 commands/rsh/Makefile | 4 + commands/{simple => rsh}/rsh.c | 0 commands/rshd/Makefile | 5 + commands/{simple/in.rshd.c => rshd/rshd.c} | 0 commands/screendump/Makefile | 4 + commands/{ibm => screendump}/screendump.c | 0 commands/scripts/Makefile | 192 - commands/scripts/build | 3 - commands/sdump/Makefile | 5 + commands/{ibm => sdump}/sdump.c | 12 +- commands/sed/Makefile | 5 + commands/{simple => sed}/sed.c | 0 commands/setup/Makefile | 5 + commands/{scripts => setup}/setup.sh | 0 commands/sh/Makefile | 29 - commands/sh/build | 3 - commands/sh/sh.h | 383 -- commands/sh/sh1.c | 952 ----- commands/sh/sh2.c | 800 ---- commands/sh/sh3.c | 1147 ----- commands/sh/sh4.c | 779 ---- commands/sh/sh5.c | 681 --- commands/sh/sh6.c | 8 - commands/shar/Makefile | 4 + commands/{simple => shar}/shar.c | 0 commands/simple/Makefile | 1730 -------- commands/simple/build | 3 - commands/simple/origmkfs.c | 1341 ------ commands/size/Makefile | 4 + commands/{simple => size}/size.c | 0 commands/sleep/Makefile | 4 + commands/{simple => sleep}/sleep.c | 0 commands/slip/Makefile | 4 + commands/{simple => slip}/slip.c | 0 commands/sort/Makefile | 4 + commands/{simple => sort}/sort.c | 0 commands/spell/Makefile | 4 + commands/{scripts => spell}/spell.sh | 0 commands/split/Makefile | 4 + commands/{simple => split}/split.c | 0 commands/srccrc/Makefile | 4 + commands/{scripts => srccrc}/srccrc.sh | 0 commands/stat/Makefile | 7 + commands/{simple => stat}/stat.c | 0 commands/strings/Makefile | 4 + commands/{simple => strings}/strings.c | 0 commands/strip/Makefile | 4 + commands/{simple => strip}/strip.c | 0 commands/stty/Makefile | 4 + commands/{simple => stty}/stty.c | 0 commands/su/Makefile | 5 + commands/{simple => su}/su.c | 0 commands/sum/Makefile | 4 + commands/{simple => sum}/sum.c | 0 commands/svclog/Makefile | 4 + commands/{scripts => svclog}/svclog.sh | 0 commands/swapfs/Makefile | 4 + commands/{simple => swapfs}/swapfs.c | 0 commands/swifi/Makefile | 28 +- commands/swifi/ddb.h | 2 - commands/sync/Makefile | 5 + commands/{simple => sync}/sync.c | 0 commands/synctree/Makefile | 5 + commands/{simple => synctree}/synctree.c | 0 commands/sysenv/Makefile | 5 + commands/{simple => sysenv}/sysenv.c | 0 commands/syslogd/Makefile | 42 +- commands/syslogd/syslog.c | 167 - commands/syslogd/syslog_test.c | 30 - commands/tail/Makefile | 4 + commands/{simple => tail}/tail.c | 0 commands/talk/Makefile | 28 +- commands/talk/build | 3 - commands/talkd/Makefile | 27 +- commands/talkd/build | 3 - commands/tcpd/Makefile | 5 + commands/{simple => tcpd}/tcpd.c | 0 commands/tcpdp/Makefile | 10 + commands/tcpdp/tcpd.c | 311 ++ commands/tcpstat/Makefile | 5 + commands/{simple => tcpstat}/tcpstat.c | 0 commands/tee/Makefile | 4 + commands/{simple => tee}/tee.c | 0 commands/telnet/Makefile | 22 +- commands/telnet/build | 3 - commands/telnetd/Makefile | 28 +- commands/telnetd/build | 3 - commands/term/Makefile | 6 + commands/{simple => term}/term.c | 0 commands/termcap/Makefile | 4 + commands/{simple => termcap}/termcap.c | 0 commands/tget/Makefile | 4 + commands/{simple => tget}/tget.c | 0 commands/time/Makefile | 4 + commands/{simple => time}/time.c | 0 commands/tinyhalt/Makefile | 11 + commands/tinyhalt/README | 1 + commands/{reboot => tinyhalt}/tinyhalt.c | 0 commands/top/Makefile | 9 + commands/{simple => top}/top.c | 6 +- commands/touch/Makefile | 4 + commands/{simple => touch}/touch.c | 0 commands/tr/Makefile | 5 + commands/{simple => tr}/str.c | 0 commands/{simple => tr}/tr.c | 0 commands/{simple => tr}/tr.h | 0 commands/truncate/Makefile | 4 + commands/{simple => truncate}/truncate.c | 0 commands/tsort/Makefile | 4 + commands/{simple => tsort}/tsort.c | 0 commands/ttt/Makefile | 4 + commands/{simple => ttt}/ttt.c | 0 commands/tty/Makefile | 4 + commands/{simple => tty}/tty.c | 0 commands/udpstat/Makefile | 5 + commands/{simple => udpstat}/udpstat.c | 0 commands/umount/Makefile | 6 + commands/{simple => umount}/umount.c | 0 commands/uname/Makefile | 6 + commands/{simple => uname}/uname.c | 0 commands/unexpand/Makefile | 4 + commands/{simple => unexpand}/unexpand.c | 0 commands/uniq/Makefile | 4 + commands/{simple => uniq}/uniq.c | 0 commands/unstack/Makefile | 4 + commands/{scripts => unstack}/unstack.sh | 0 commands/update/Makefile | 4 + commands/{simple => update}/update.c | 0 commands/urlget/Makefile | 34 +- commands/urlget/build | 3 - commands/uud/Makefile | 6 + commands/{simple => uud}/uud.c | 0 commands/uue/Makefile | 6 + commands/{simple => uue}/uue.c | 0 commands/version/Makefile | 4 + commands/{scripts => version}/version.sh | 0 commands/vol/Makefile | 4 + commands/{simple => vol}/vol.c | 0 commands/wc/Makefile | 4 + commands/{simple => wc}/wc.c | 0 commands/whatis/Makefile | 6 + commands/{scripts => whatis}/whatis.sh | 0 commands/whereis/Makefile | 4 + commands/{scripts => whereis}/whereis.sh | 0 commands/which/Makefile | 4 + commands/{simple => which}/which.c | 0 commands/who/Makefile | 4 + commands/{simple => who}/who.c | 0 commands/whoami/Makefile | 4 + commands/{simple => whoami}/whoami.c | 0 commands/write/Makefile | 6 + commands/{simple => write}/write.c | 0 commands/writeisofs/Makefile | 4 + commands/{simple => writeisofs}/writeisofs.c | 0 commands/xargs/Makefile | 4 + commands/{simple => xargs}/xargs.c | 0 .../ACKNOWLEDGEMEN => yacc/ACKNOWLEDGEMENTS} | 0 commands/yacc/Makefile | 7 + commands/{byacc => yacc}/NEW_FEATURES | 0 commands/yacc/NOTES | 21 + commands/{byacc => yacc}/README | 0 commands/{byacc => yacc}/closure.c | 129 +- commands/{byacc => yacc}/defs.h | 140 +- commands/{byacc => yacc}/error.c | 218 +- commands/{byacc => yacc}/lalr.c | 286 +- commands/{byacc => yacc}/lr0.c | 262 +- commands/yacc/main.c | 484 +++ commands/{byacc => yacc}/mkpar.c | 230 +- commands/{byacc => yacc}/output.c | 332 +- commands/{byacc => yacc}/reader.c | 407 +- commands/{byacc => yacc}/skeleton.c | 173 +- commands/yacc/symtab.c | 161 + commands/yacc/test/error.output | 27 + commands/yacc/test/error.tab.c | 276 ++ commands/yacc/test/error.tab.h | 2 + commands/yacc/test/error.y | 6 + commands/yacc/test/ftp.output | 1625 ++++++++ commands/yacc/test/ftp.tab.c | 1745 ++++++++ commands/yacc/test/ftp.tab.h | 65 + commands/yacc/test/ftp.y | 1185 ++++++ commands/{byacc => yacc}/verbose.c | 160 +- commands/yacc/warshall.c | 125 + commands/yacc/yacc.1 | 188 + commands/yap/Makefile | 217 +- commands/yap/build | 5 - commands/yap/pattern.c | 20 +- commands/yes/Makefile | 4 + commands/{simple => yes}/yes.c | 0 commands/zdump/Makefile | 11 + commands/zic/Makefile | 11 + commands/zmodem/Makefile | 27 +- commands/zmodem/build | 3 - commands/zoneinfo/newctime.3 | 1 - commands/zoneinfo/newstrftime.3 | 1 - commands/zoneinfo/newtzset.3 | 1 - commands/zoneinfo/time2posix.3 | 1 - commands/zoneinfo/tzfile.5 | 1 - commands/zoneinfo/tzselect.8 | 1 - commands/zoneinfo/zdump.8 | 1 - commands/zoneinfo/zic.8 | 1 - docs/UPDATING | 7 + drivers/memory/ramdisk/Makefile | 40 +- drivers/tty/keymaps/Makefile.inc | 5 +- etc/Makefile | 10 +- etc/mk/minix.ack.mk | 2 +- etc/mk/minix.inc.mk | 18 +- etc/mk/minix.own.mk | 4 +- etc/mk/minix.prog.mk | 13 +- etc/mtree/minix.tree | 104 +- include/sys/Makefile | 2 +- include/sys/cdefs.h | 450 ++ lib/Makefile | 2 +- lib/libbz2/Makefile | 14 + lib/libc/other/syslog.c | 2 +- lib/libc/stdtime/Makefile.inc | 6 - {man/man1 => lib/libc/stdtime}/date.1 | 0 .../zoneinfo => lib/libc/stdtime}/date.c | 0 .../zoneinfo => lib/libc/stdtime}/difftime.c | 0 .../zoneinfo => lib/libc/stdtime}/ialloc.c | 0 .../zoneinfo => lib/libc/stdtime}/logwtmp.c | 0 .../zoneinfo => lib/libc/stdtime}/private.h | 0 .../zoneinfo => lib/libc/stdtime}/scheck.c | 0 .../zoneinfo => lib/libc/stdtime}/tzfile.h | 0 {man/man8 => lib/libc/stdtime}/zdump.8 | 0 .../zoneinfo => lib/libc/stdtime}/zdump.c | 0 {man/man8 => lib/libc/stdtime}/zic.8 | 0 {commands/zoneinfo => lib/libc/stdtime}/zic.c | 0 lib/libl/Makefile | 12 + man/man1/Makefile | 10 +- man/man1/flex.1 | 780 ---- man/man1/ftp.1 | 150 - man/man1/yacc.1 | 111 - man/man8/Makefile | 2 +- man/man8/tzselect.8 | 41 - share/Makefile | 5 + share/zoneinfo/Makefile | 112 + .../Makefile => share/zoneinfo/Makefile.orig | 0 {commands => share}/zoneinfo/README | 0 {commands => share}/zoneinfo/Theory | 0 {commands => share}/zoneinfo/africa | 0 {commands => share}/zoneinfo/antarctica | 0 {commands => share}/zoneinfo/asia | 0 {commands => share}/zoneinfo/australasia | 0 {commands => share}/zoneinfo/backward | 0 {commands => share}/zoneinfo/checktab.awk | 0 {commands => share}/zoneinfo/etcetera | 0 {commands => share}/zoneinfo/europe | 0 {commands => share}/zoneinfo/factory | 0 {commands => share}/zoneinfo/iso3166.tab | 0 {commands => share}/zoneinfo/itca.jpg | Bin {commands => share}/zoneinfo/leapseconds | 0 {commands => share}/zoneinfo/northamerica | 0 {commands => share}/zoneinfo/pacificnew | 0 {commands => share}/zoneinfo/solar87 | 0 {commands => share}/zoneinfo/solar88 | 0 {commands => share}/zoneinfo/solar89 | 0 {commands => share}/zoneinfo/southamerica | 0 {commands => share}/zoneinfo/systemv | 0 {commands => share}/zoneinfo/tz-art.htm | 0 {commands => share}/zoneinfo/tz-link.htm | 0 {commands => share}/zoneinfo/tzselect.ksh | 0 {commands => share}/zoneinfo/usno1988 | 0 {commands => share}/zoneinfo/usno1989 | 0 {commands => share}/zoneinfo/usno1989a | 0 {commands => share}/zoneinfo/usno1995 | 0 {commands => share}/zoneinfo/usno1997 | 0 {commands => share}/zoneinfo/usno1998 | 0 {commands => share}/zoneinfo/workman.sh | 0 {commands => share}/zoneinfo/yearistype.sh | 0 {commands => share}/zoneinfo/zone.tab | 0 test/ipc/semctl/Makefile | 2 +- test/ipc/semget/Makefile | 2 +- test/ipc/semop/Makefile | 2 +- test/ipc/shmat/Makefile | 2 +- test/ipc/shmctl/Makefile | 2 +- test/ipc/shmdt/Makefile | 2 +- test/ipc/shmget/Makefile | 2 +- test/ipc/shmt/Makefile | 2 +- test/select/Makefile | 2 +- test/testsh1.sh | 8 +- tools/chrootmake.sh | 6 +- tools/release.sh | 17 +- 877 files changed, 10425 insertions(+), 41539 deletions(-) rename commands/{scripts => DESCRIBE}/DESCRIBE.sh (100%) mode change 100755 => 100644 create mode 100644 commands/DESCRIBE/Makefile rename commands/{scripts => M}/M.sh (100%) mode change 100755 => 100644 create mode 100644 commands/M/Makefile rename commands/{scripts => MAKEDEV}/MAKEDEV.sh (100%) mode change 100755 => 100644 create mode 100644 commands/MAKEDEV/Makefile create mode 100644 commands/Makefile.inc delete mode 100755 commands/aal/build create mode 100644 commands/acd/Makefile rename commands/{i386 => acd}/acd.c (100%) rename commands/{i386 => acd}/acd.descr (100%) create mode 100644 commands/add_route/Makefile rename commands/{simple => add_route}/add_route.c (100%) create mode 100644 commands/adduser/Makefile rename commands/{scripts => adduser}/adduser.sh (100%) mode change 100755 => 100644 delete mode 100755 commands/advent/build create mode 100644 commands/arp/Makefile rename commands/{simple => arp}/arp.c (100%) delete mode 100644 commands/ash/arith.h create mode 100644 commands/asmconv/Makefile rename commands/{i386 => }/asmconv/asm86.c (100%) rename commands/{i386 => }/asmconv/asm86.h (100%) rename commands/{i386 => }/asmconv/asmconv.c (100%) rename commands/{i386 => }/asmconv/asmconv.h (100%) rename commands/{i386 => }/asmconv/emit_ack.c (100%) rename commands/{i386 => }/asmconv/emit_gnu.c (100%) rename commands/{i386 => }/asmconv/languages.h (100%) rename commands/{i386 => }/asmconv/parse_ack.c (100%) rename commands/{i386 => }/asmconv/parse_bas.c (100%) rename commands/{i386 => }/asmconv/parse_gnu.c (100%) rename commands/{i386 => }/asmconv/syntax.ack (100%) rename commands/{i386 => }/asmconv/token.h (100%) rename commands/{i386 => }/asmconv/tokenize.c (100%) create mode 100644 commands/at/Makefile rename commands/{simple => at}/at.c (100%) create mode 100644 commands/atnormalize/Makefile rename commands/{ibm => atnormalize}/atnormalize.c (100%) delete mode 100755 commands/autil/build create mode 100644 commands/autopart/Makefile rename commands/{ibm => autopart}/autopart.c (100%) create mode 100644 commands/awk/Makefile.orig delete mode 100644 commands/awk/buildwin.bat delete mode 100644 commands/awk/makefile.win delete mode 100644 commands/awk/missing95.c create mode 100644 commands/awk/proctab.c delete mode 100644 commands/awk/vcvars32.bat delete mode 100644 commands/awk/ytabc.bak delete mode 100644 commands/awk/ytabh.bak create mode 100644 commands/backup/Makefile rename commands/{simple => backup}/backup.c (100%) create mode 100644 commands/badblocks/Makefile rename commands/{simple => badblocks}/badblocks.c (99%) create mode 100644 commands/banner/Makefile rename commands/{simple => banner}/banner.c (100%) create mode 100644 commands/basename/Makefile rename commands/{simple => basename}/basename.c (100%) create mode 100644 commands/bigmake/Makefile rename commands/{scripts => bigmake}/bigmake.sh (100%) create mode 100644 commands/binpackage/Makefile rename commands/{scripts => binpackage}/binpackage.sh (100%) create mode 100644 commands/binpackages/Makefile rename commands/{scripts => binpackages}/binpackages.sh (100%) create mode 100644 commands/binsizes/Makefile rename commands/{scripts => binsizes}/binsizes.sh (100%) delete mode 100644 commands/byacc/MANIFEST delete mode 100644 commands/byacc/Makefile delete mode 100644 commands/byacc/NOTES delete mode 100644 commands/byacc/NO_WARRANTY delete mode 100755 commands/byacc/build delete mode 100644 commands/byacc/main.c delete mode 100644 commands/byacc/symtab.c delete mode 100644 commands/byacc/warshall.c delete mode 100644 commands/bzip2-1.0.3/README.MINIX delete mode 100755 commands/bzip2-1.0.3/build delete mode 120000 commands/bzip2-1.0.3/bzdiff.1 delete mode 120000 commands/bzip2-1.0.3/bzgrep.1 delete mode 120000 commands/bzip2-1.0.3/bzip2.1 delete mode 120000 commands/bzip2-1.0.3/bzmore.1 rename commands/{bzip2-1.0.3 => bzip2}/CHANGES (100%) rename commands/{bzip2-1.0.3 => bzip2}/LICENSE (100%) create mode 100644 commands/bzip2/Makefile rename commands/{bzip2-1.0.3 => bzip2}/Makefile-libbz2_so (100%) rename commands/{bzip2-1.0.3/Makefile => bzip2/Makefile.orig} (100%) rename commands/{bzip2-1.0.3/README.ORIGINAL => bzip2/README} (100%) rename commands/{bzip2-1.0.3 => bzip2}/README.COMPILATION.PROBLEMS (100%) rename commands/{bzip2-1.0.3 => bzip2}/README.XML.STUFF (100%) rename commands/{bzip2-1.0.3 => bzip2}/Y2K_INFO (100%) rename commands/{bzip2-1.0.3 => bzip2}/blocksort.c (100%) rename commands/{bzip2-1.0.3 => bzip2}/bz-common.xsl (100%) rename commands/{bzip2-1.0.3 => bzip2}/bz-fo.xsl (100%) rename commands/{bzip2-1.0.3 => bzip2}/bz-html.xsl (100%) rename commands/{bzip2-1.0.3 => bzip2}/bzdiff (100%) rename {man/man1 => commands/bzip2}/bzdiff.1 (100%) rename commands/{bzip2-1.0.3 => bzip2}/bzgrep (100%) rename {man/man1 => commands/bzip2}/bzgrep.1 (100%) rename commands/{bzip2-1.0.3 => bzip2}/bzip.css (100%) rename {man/man1 => commands/bzip2}/bzip2.1 (100%) rename commands/{bzip2-1.0.3 => bzip2}/bzip2.1.preformatted (100%) rename commands/{bzip2-1.0.3 => bzip2}/bzip2.c (100%) rename commands/{bzip2-1.0.3 => bzip2}/bzip2.txt (100%) rename commands/{bzip2-1.0.3 => bzip2}/bzip2recover.c (100%) rename commands/{bzip2-1.0.3 => bzip2}/bzlib.c (100%) rename commands/{bzip2-1.0.3 => bzip2}/bzlib.h (100%) rename commands/{bzip2-1.0.3 => bzip2}/bzlib_private.h (100%) rename commands/{bzip2-1.0.3 => bzip2}/bzmore (100%) rename {man/man1 => commands/bzip2}/bzmore.1 (100%) rename commands/{bzip2-1.0.3 => bzip2}/compress.c (100%) rename commands/{bzip2-1.0.3 => bzip2}/crctable.c (100%) rename commands/{bzip2-1.0.3 => bzip2}/decompress.c (100%) rename commands/{bzip2-1.0.3 => bzip2}/dlltest.c (100%) rename commands/{bzip2-1.0.3 => bzip2}/dlltest.dsp (100%) rename commands/{bzip2-1.0.3 => bzip2}/entities.xml (100%) rename commands/{bzip2-1.0.3 => bzip2}/format.pl (100%) rename commands/{bzip2-1.0.3 => bzip2}/huffman.c (100%) rename commands/{bzip2-1.0.3 => bzip2}/libbz2.def (100%) rename commands/{bzip2-1.0.3 => bzip2}/libbz2.dsp (100%) rename commands/{bzip2-1.0.3 => bzip2}/makefile.msc (100%) rename commands/{bzip2-1.0.3 => bzip2}/mk251.c (100%) rename commands/{bzip2-1.0.3 => bzip2}/randtable.c (100%) rename commands/{bzip2-1.0.3 => bzip2}/sample1.bz2 (100%) rename commands/{bzip2-1.0.3 => bzip2}/sample1.ref (100%) rename commands/{bzip2-1.0.3 => bzip2}/sample2.bz2 (100%) rename commands/{bzip2-1.0.3 => bzip2}/sample2.ref (100%) rename commands/{bzip2-1.0.3 => bzip2}/sample3.bz2 (100%) rename commands/{bzip2-1.0.3 => bzip2}/sample3.ref (100%) rename commands/{bzip2-1.0.3 => bzip2}/spewG.c (100%) rename commands/{bzip2-1.0.3 => bzip2}/unzcrash.c (100%) rename commands/{bzip2-1.0.3 => bzip2}/words0 (100%) rename commands/{bzip2-1.0.3 => bzip2}/words1 (100%) rename commands/{bzip2-1.0.3 => bzip2}/words2 (100%) rename commands/{bzip2-1.0.3 => bzip2}/words3 (100%) rename commands/{bzip2-1.0.3 => bzip2}/xmlproc.sh (100%) create mode 100644 commands/bzip2recover/Makefile create mode 100644 commands/cal/Makefile rename commands/{simple => cal}/cal.c (100%) create mode 100644 commands/calendar/Makefile rename commands/{simple => calendar}/calendar.c (100%) create mode 100644 commands/cat/Makefile rename commands/{simple => cat}/cat.c (100%) delete mode 100755 commands/cawf/build create mode 100644 commands/cd/Makefile rename commands/{scripts => cd}/cd.sh (100%) mode change 100755 => 100644 create mode 100644 commands/cdiff/Makefile rename commands/{simple => cdiff}/cdiff.c (100%) create mode 100644 commands/cdprobe/Makefile rename commands/{simple => cdprobe}/cdprobe.c (98%) create mode 100644 commands/cgrep/Makefile rename commands/{simple => cgrep}/cgrep.c (100%) create mode 100644 commands/checkhier/Makefile rename commands/{scripts => checkhier}/checkhier.sh (100%) mode change 100755 => 100644 create mode 100644 commands/chmem/Makefile rename commands/{simple => chmem}/chmem.c (100%) create mode 100644 commands/chmod/Makefile rename commands/{simple => chmod}/chmod.c (100%) create mode 100644 commands/chown/Makefile rename commands/{simple => chown}/chown.c (100%) create mode 100644 commands/chroot/Makefile rename commands/{simple => chroot}/chroot.c (100%) create mode 100644 commands/ci/Makefile rename commands/{simple => ci}/ci.c (100%) create mode 100644 commands/cksum/Makefile rename commands/{simple => cksum}/cksum.c (100%) create mode 100644 commands/cleantmp/Makefile rename commands/{simple => cleantmp}/cleantmp.c (100%) create mode 100644 commands/clear/Makefile rename commands/{scripts => clear}/clear.sh (100%) mode change 100755 => 100644 create mode 100644 commands/cmp/Makefile rename commands/{simple => cmp}/cmp.c (100%) create mode 100644 commands/co/Makefile rename commands/{simple => co}/co.c (100%) create mode 100644 commands/comm/Makefile rename commands/{simple => comm}/comm.c (100%) create mode 100644 commands/compress/Makefile rename commands/{simple => compress}/compress.c (100%) create mode 100644 commands/cp/Makefile rename commands/{simple => cp}/cp.c (100%) create mode 100644 commands/crc/Makefile rename commands/{simple => crc}/crc.c (100%) delete mode 100755 commands/cron/build create mode 100644 commands/crontab/Makefile rename commands/{cron => crontab}/crontab.c (100%) create mode 100644 commands/cut/Makefile rename commands/{simple => cut}/cut.c (100%) create mode 100644 commands/datasizes/Makefile rename commands/{scripts => datasizes}/datasizes.sh (100%) create mode 100644 commands/date/Makefile create mode 100644 commands/dd/Makefile rename commands/{simple => dd}/dd.c (100%) delete mode 100755 commands/de/build create mode 100644 commands/decomp16/Makefile rename commands/{simple => decomp16}/decomp16.c (100%) create mode 100644 commands/dev2name/Makefile rename commands/{simple => dev2name}/dev2name.c (100%) create mode 100644 commands/devsize/Makefile rename commands/{simple => devsize}/devsize.c (100%) create mode 100644 commands/df/Makefile rename commands/{simple => df}/df.c (100%) delete mode 100755 commands/dhcpd/build create mode 100644 commands/dhrystone/Makefile rename commands/{simple => dhrystone}/dhrystone.c (100%) create mode 100644 commands/diff/Makefile rename commands/{simple => diff}/diff.c (100%) create mode 100644 commands/dirname/Makefile rename commands/{simple => dirname}/dirname.c (100%) delete mode 100755 commands/dis88/build create mode 100644 commands/dosread/Makefile rename commands/{ibm => dosread}/dosread.c (100%) create mode 100644 commands/du/Makefile rename commands/{simple => du}/du.c (100%) create mode 100644 commands/dumpcore/Makefile rename commands/{simple => dumpcore}/dumpcore.c (99%) create mode 100644 commands/easypack/Makefile rename commands/{scripts => easypack}/easypack.sh (100%) create mode 100644 commands/ed/Makefile rename commands/{simple => ed}/ed.c (100%) create mode 100644 commands/eject/Makefile rename commands/{simple => eject}/eject.c (100%) delete mode 100755 commands/elle/build delete mode 100755 commands/elvis/build create mode 100644 commands/env/Makefile rename commands/{simple => env}/env.c (100%) create mode 100644 commands/expand/Makefile rename commands/{simple => expand}/expand.c (100%) create mode 100644 commands/factor/Makefile rename commands/{simple => factor}/factor.c (100%) create mode 100644 commands/fdisk/Makefile rename commands/{ibm => fdisk}/fdisk.c (100%) create mode 100644 commands/fgrep/Makefile rename commands/{simple => fgrep}/fgrep.c (100%) create mode 100644 commands/file/Makefile rename commands/{simple => file}/file.c (100%) create mode 100644 commands/find/Makefile rename commands/{simple => find}/find.c (100%) create mode 100644 commands/finger/Makefile rename commands/{simple => finger}/finger.c (100%) create mode 100644 commands/fingerd/Makefile rename commands/{simple/in.fingerd.c => fingerd/fingerd.c} (100%) create mode 100644 commands/fix/Makefile rename commands/{simple => fix}/fix.c (100%) delete mode 100644 commands/flex-2.5.4/.descr delete mode 100644 commands/flex-2.5.4/INSTALL delete mode 100644 commands/flex-2.5.4/MISC/Amiga/README.amiga delete mode 100644 commands/flex-2.5.4/MISC/Amiga/SMakefile delete mode 100644 commands/flex-2.5.4/MISC/Amiga/config.h delete mode 100644 commands/flex-2.5.4/MISC/Amiga/libmain.ch delete mode 100644 commands/flex-2.5.4/MISC/Amiga/libyywrap.ch delete mode 100644 commands/flex-2.5.4/MISC/Amiga/parse.ych delete mode 100644 commands/flex-2.5.4/MISC/Atari/Atari.patches delete mode 100644 commands/flex-2.5.4/MISC/Borland.old/Borland-2.4 delete mode 100644 commands/flex-2.5.4/MISC/Borland.old/Turbo-C delete mode 100644 commands/flex-2.5.4/MISC/Borland/Makefile delete mode 100644 commands/flex-2.5.4/MISC/Borland/NOTES delete mode 100644 commands/flex-2.5.4/MISC/Borland/config.h delete mode 100644 commands/flex-2.5.4/MISC/EBCDIC delete mode 100644 commands/flex-2.5.4/MISC/MSDOS/MSC70.make delete mode 100644 commands/flex-2.5.4/MISC/MSDOS/configur.bat delete mode 100644 commands/flex-2.5.4/MISC/MSDOS/djgpp.sed delete mode 100644 commands/flex-2.5.4/MISC/MVS/MVS.mail delete mode 100644 commands/flex-2.5.4/MISC/MVS/MVS.todo delete mode 100644 commands/flex-2.5.4/MISC/MVS/MVS.uudecode delete mode 100644 commands/flex-2.5.4/MISC/MVS/README delete mode 100644 commands/flex-2.5.4/MISC/MVS/diffs delete mode 100644 commands/flex-2.5.4/MISC/MVS/fixit.l delete mode 100644 commands/flex-2.5.4/MISC/MVS/initscan-mvs.c delete mode 100644 commands/flex-2.5.4/MISC/MVS/unfixit.l delete mode 100644 commands/flex-2.5.4/MISC/Macintosh/THINK_C_notes delete mode 100644 commands/flex-2.5.4/MISC/Macintosh/alloca.c delete mode 100644 commands/flex-2.5.4/MISC/Macintosh/alloca.h delete mode 100644 commands/flex-2.5.4/MISC/Macintosh/xmalloc.c delete mode 100644 commands/flex-2.5.4/MISC/NT/Makefile delete mode 100644 commands/flex-2.5.4/MISC/NeXT delete mode 100644 commands/flex-2.5.4/MISC/OS2/Makefile.os2 delete mode 100644 commands/flex-2.5.4/MISC/OS2/config.h delete mode 100644 commands/flex-2.5.4/MISC/README delete mode 100644 commands/flex-2.5.4/MISC/VMS/README.VMS delete mode 100644 commands/flex-2.5.4/MISC/VMS/build.com delete mode 100644 commands/flex-2.5.4/MISC/VMS/descrip.mms delete mode 100644 commands/flex-2.5.4/MISC/VMS/mkskel.tpu delete mode 100644 commands/flex-2.5.4/MISC/VMS/vms-code.c delete mode 100644 commands/flex-2.5.4/MISC/VMS/vms-conf.h delete mode 100644 commands/flex-2.5.4/MISC/alloca.c delete mode 100644 commands/flex-2.5.4/MISC/debflex.awk delete mode 100644 commands/flex-2.5.4/MISC/fastwc/README delete mode 100644 commands/flex-2.5.4/MISC/fastwc/mywc.c delete mode 100644 commands/flex-2.5.4/MISC/fastwc/wc1.l delete mode 100644 commands/flex-2.5.4/MISC/fastwc/wc2.l delete mode 100644 commands/flex-2.5.4/MISC/fastwc/wc3.l delete mode 100644 commands/flex-2.5.4/MISC/fastwc/wc4.l delete mode 100644 commands/flex-2.5.4/MISC/fastwc/wc5.l delete mode 100644 commands/flex-2.5.4/MISC/flex.man delete mode 100644 commands/flex-2.5.4/MISC/parse.c delete mode 100644 commands/flex-2.5.4/MISC/parse.h delete mode 100644 commands/flex-2.5.4/MISC/testxxLexer.l delete mode 100644 commands/flex-2.5.4/MISC/texinfo/flex.info delete mode 100644 commands/flex-2.5.4/MISC/texinfo/flex.texi delete mode 100644 commands/flex-2.5.4/Makefile.in delete mode 100644 commands/flex-2.5.4/README delete mode 100755 commands/flex-2.5.4/build delete mode 100644 commands/flex-2.5.4/conf.in delete mode 100755 commands/flex-2.5.4/configure delete mode 100644 commands/flex-2.5.4/configure.in delete mode 100755 commands/flex-2.5.4/configure.minix delete mode 100755 commands/flex-2.5.4/install.sh delete mode 100755 commands/flex-2.5.4/mkinstalldirs delete mode 100644 commands/flex-2.5.4/skel.c create mode 100644 commands/fold/Makefile rename commands/{simple => fold}/fold.c (100%) create mode 100644 commands/format/Makefile rename commands/{ibm => format}/format.c (100%) create mode 100644 commands/fortune/Makefile rename commands/{simple => fortune}/fortune.c (100%) create mode 100644 commands/fsck/Makefile rename commands/{simple => fsck}/fsck.c (99%) create mode 100644 commands/fsck1/Makefile rename commands/{simple => fsck1}/fsck1.c (99%) delete mode 100755 commands/ftpd200/build create mode 100644 commands/gas2ack/Makefile rename commands/{i386 => }/gas2ack/asm86.c (100%) rename commands/{i386 => }/gas2ack/asm86.h (100%) rename commands/{i386 => }/gas2ack/asmconv.h (100%) rename commands/{i386 => }/gas2ack/emit_ack.c (100%) rename commands/{i386 => }/gas2ack/gas2ack.c (100%) rename commands/{i386 => }/gas2ack/globals.c (100%) rename commands/{i386 => }/gas2ack/globals.h (100%) rename commands/{i386 => }/gas2ack/languages.h (100%) rename commands/{i386 => }/gas2ack/parse_gnu.c (100%) rename commands/{i386 => }/gas2ack/token.h (100%) rename commands/{i386 => }/gas2ack/tokenize.c (100%) create mode 100644 commands/getty/Makefile rename commands/{simple => getty}/getty.c (100%) create mode 100644 commands/gomoku/Makefile rename commands/{simple => gomoku}/gomoku.c (100%) create mode 100644 commands/grep/Makefile rename commands/{simple => grep}/grep.c (100%) create mode 100644 commands/head/Makefile rename commands/{simple => head}/head.c (100%) create mode 100644 commands/host/Makefile rename commands/{simple => host}/host.c (100%) create mode 100644 commands/hostaddr/Makefile rename commands/{simple => hostaddr}/hostaddr.c (100%) delete mode 100644 commands/i386/Makefile delete mode 100644 commands/i386/asmconv/Makefile delete mode 100755 commands/i386/asmconv/build delete mode 100755 commands/i386/build delete mode 100644 commands/i386/gas2ack/Makefile delete mode 100644 commands/ibm/Makefile delete mode 100755 commands/ibm/build create mode 100644 commands/id/Makefile rename commands/{simple => id}/id.c (100%) create mode 100644 commands/ifconfig/Makefile rename commands/{simple => ifconfig}/ifconfig.c (100%) create mode 100644 commands/ifdef/Makefile rename commands/{simple => ifdef}/ifdef.c (100%) delete mode 100755 commands/indent/build create mode 100644 commands/install/Makefile rename commands/{simple => install}/install.c (100%) create mode 100644 commands/intr/Makefile rename commands/{simple => intr}/intr.c (100%) create mode 100644 commands/ipcrm/Makefile rename commands/{simple => ipcrm}/ipcrm.c (100%) create mode 100644 commands/ipcs/Makefile rename commands/{simple => ipcs}/ipcs.c (100%) create mode 100644 commands/irdpd/Makefile rename commands/{simple => irdpd}/irdpd.c (100%) create mode 100644 commands/isoread/Makefile rename commands/{simple => isoread}/isoread.c (100%) create mode 100644 commands/join/Makefile rename commands/{simple => join}/join.c (100%) create mode 100644 commands/kill/Makefile rename commands/{simple => kill}/kill.c (100%) create mode 100644 commands/last/Makefile rename commands/{simple => last}/last.c (100%) create mode 100644 commands/leave/Makefile rename commands/{simple => leave}/leave.c (100%) rename commands/{flex-2.5.4 => lex}/COPYING (100%) rename commands/{flex-2.5.4 => lex}/FlexLexer.h (100%) create mode 100644 commands/lex/Makefile rename commands/{flex-2.5.4 => lex}/NEWS (100%) rename commands/{flex-2.5.4 => lex}/ccl.c (100%) rename commands/{flex-2.5.4/MISC/NT => lex}/config.h (64%) rename commands/{flex-2.5.4 => lex}/dfa.c (100%) rename commands/{flex-2.5.4 => lex}/ecs.c (100%) rename commands/{flex-2.5.4 => lex}/flex.1 (100%) rename commands/{flex-2.5.4 => lex}/flex.skl (100%) rename commands/{flex-2.5.4 => lex}/flexdef.h (100%) rename commands/{flex-2.5.4 => lex}/gen.c (100%) rename commands/{flex-2.5.4 => lex}/initscan.c (100%) rename commands/{flex-2.5.4 => lex}/libmain.c (100%) rename commands/{flex-2.5.4 => lex}/libyywrap.c (100%) rename commands/{flex-2.5.4 => lex}/main.c (100%) rename commands/{flex-2.5.4 => lex}/misc.c (100%) rename commands/{flex-2.5.4 => lex}/mkskel.sh (100%) rename commands/{flex-2.5.4 => lex}/nfa.c (100%) rename commands/{flex-2.5.4 => lex}/parse.y (100%) rename commands/{flex-2.5.4 => lex}/scan.l (100%) rename commands/{flex-2.5.4 => lex}/sym.c (100%) rename commands/{flex-2.5.4 => lex}/tblcmp.c (100%) rename commands/{flex-2.5.4 => lex}/version.h (100%) rename commands/{flex-2.5.4 => lex}/yylex.c (100%) create mode 100644 commands/life/Makefile rename commands/{simple => life}/life.c (100%) create mode 100644 commands/loadfont/Makefile rename commands/{ibm => loadfont}/loadfont.c (100%) create mode 100644 commands/loadkeys/Makefile rename commands/{ibm => loadkeys}/loadkeys.c (100%) create mode 100644 commands/loadramdisk/Makefile rename commands/{simple => loadramdisk}/loadramdisk.c (100%) create mode 100644 commands/logger/Makefile rename commands/{syslogd => logger}/logger.c (100%) create mode 100644 commands/login/Makefile rename commands/{simple => login}/login.c (100%) create mode 100644 commands/look/Makefile rename commands/{simple => look}/look.c (100%) create mode 100644 commands/lp/Makefile rename commands/{simple => lp}/lp.c (100%) create mode 100644 commands/lpd/Makefile rename commands/{simple => lpd}/lpd.c (100%) create mode 100644 commands/ls/Makefile rename commands/{simple => ls}/ls.c (100%) create mode 100644 commands/lspci/Makefile rename commands/{simple => lspci}/lspci.c (100%) delete mode 100755 commands/m4/build create mode 100644 commands/mail/Makefile rename commands/{simple => mail}/mail.c (100%) create mode 100644 commands/makewhatis/Makefile rename commands/{scripts => makewhatis}/makewhatis.sh (100%) mode change 100755 => 100644 create mode 100644 commands/man/Makefile rename commands/{simple => man}/man.c (100%) delete mode 100755 commands/mdb/build create mode 100644 commands/mesg/Makefile rename commands/{simple => mesg}/mesg.c (100%) delete mode 100755 commands/mined/build create mode 100644 commands/mixer/Makefile rename commands/{ibm => mixer}/mixer.c (100%) create mode 100644 commands/mkdep/Makefile rename commands/{scripts => mkdep}/mkdep.sh (100%) create mode 100644 commands/mkdir/Makefile rename commands/{simple => mkdir}/mkdir.c (100%) create mode 100644 commands/mkdist/Makefile rename commands/{scripts => mkdist}/mkdist.sh (100%) mode change 100755 => 100644 create mode 100644 commands/mkfifo/Makefile rename commands/{simple => mkfifo}/mkfifo.c (100%) create mode 100644 commands/mkfs/Makefile rename commands/{simple => mkfs}/mkfs.c (99%) create mode 100644 commands/mknod/Makefile rename commands/{simple => mknod}/mknod.c (100%) create mode 100644 commands/mkproto/Makefile rename commands/{simple => mkproto}/mkproto.c (100%) create mode 100644 commands/modem/Makefile rename commands/{simple => modem}/modem.c (100%) create mode 100644 commands/mount/Makefile rename commands/{simple => mount}/mount.c (98%) create mode 100644 commands/mt/Makefile rename commands/{simple => mt}/mt.c (100%) create mode 100644 commands/netconf/Makefile rename commands/{scripts => netconf}/netconf.sh (100%) mode change 100755 => 100644 create mode 100644 commands/newroot/Makefile rename commands/{simple => newroot}/newroot.c (100%) create mode 100644 commands/nice/Makefile rename commands/{simple => nice}/nice.c (100%) create mode 100644 commands/nm/Makefile rename commands/{simple => nm}/nm.c (100%) create mode 100644 commands/nohup/Makefile rename commands/{simple => nohup}/nohup.c (100%) create mode 100644 commands/nonamed/Makefile rename commands/{simple => nonamed}/nonamed.c (100%) create mode 100644 commands/od/Makefile rename commands/{simple => od}/od.c (100%) create mode 100644 commands/packit/Makefile rename commands/{scripts => packit}/packit.sh (100%) create mode 100644 commands/packman/Makefile rename commands/{scripts => packman}/packman.sh (100%) create mode 100644 commands/part/Makefile rename commands/{ibm => part}/part.c (100%) create mode 100644 commands/partition/Makefile rename commands/{ibm => partition}/partition.c (100%) create mode 100644 commands/passwd/Makefile rename commands/{simple => passwd}/passwd.c (100%) create mode 100644 commands/paste/Makefile rename commands/{simple => paste}/paste.c (100%) delete mode 100755 commands/patch/build create mode 100644 commands/ping/Makefile rename commands/{simple => ping}/ping.c (100%) create mode 100644 commands/playwave/Makefile rename commands/{ibm => playwave}/playwave.c (100%) create mode 100644 commands/postinstall/Makefile rename commands/{scripts => postinstall}/postinstall.sh (100%) create mode 100644 commands/postmort/Makefile rename commands/{ibm => postmort}/postmort.c (99%) create mode 100644 commands/poweroff/Makefile rename commands/{scripts => poweroff}/poweroff.sh (100%) create mode 100644 commands/pr/Makefile rename commands/{simple => pr}/pr.c (100%) create mode 100644 commands/pr_routes/Makefile rename commands/{simple => pr_routes}/pr_routes.c (100%) create mode 100644 commands/prep/Makefile rename commands/{simple => prep}/prep.c (100%) create mode 100644 commands/printf/Makefile rename commands/{simple => printf}/printf.c (100%) create mode 100644 commands/printroot/Makefile rename commands/{simple => printroot}/printroot.c (100%) create mode 100644 commands/progressbar/Makefile rename commands/{simple => progressbar}/progressbar.c (100%) create mode 100644 commands/proto/Makefile rename commands/{simple => proto}/proto.c (100%) delete mode 100755 commands/ps/build create mode 100644 commands/pwd/Makefile rename commands/{simple => pwd}/pwd.c (100%) create mode 100644 commands/pwdauth/Makefile rename commands/{simple => pwdauth}/pwdauth.c (100%) create mode 100644 commands/ramdisk/Makefile rename commands/{simple => ramdisk}/ramdisk.c (100%) create mode 100644 commands/rarpd/Makefile rename commands/{simple => rarpd}/rarpd.c (100%) create mode 100644 commands/rawspeed/Makefile rename commands/{simple => rawspeed}/rawspeed.c (100%) create mode 100644 commands/rcp/Makefile rename commands/{simple => rcp}/rcp.c (100%) create mode 100644 commands/rdate/Makefile rename commands/{simple => rdate}/rdate.c (100%) create mode 100644 commands/readall/Makefile rename commands/{simple => readall}/readall.c (100%) create mode 100644 commands/readclock/Makefile rename commands/{scripts => readclock}/readclock.sh (100%) create mode 100644 commands/readfs/Makefile rename commands/{simple => readfs}/readfs.c (99%) delete mode 100755 commands/reboot/build create mode 100644 commands/recwave/Makefile rename commands/{ibm => recwave}/recwave.c (100%) create mode 100644 commands/remsync/Makefile rename commands/{simple => remsync}/remsync.c (100%) create mode 100644 commands/repartition/Makefile rename commands/{ibm => repartition}/repartition.c (100%) create mode 100644 commands/rev/Makefile rename commands/{simple => rev}/rev.c (100%) create mode 100644 commands/rget/Makefile rename commands/{simple => rget}/rget.c (100%) create mode 100644 commands/rlogin/Makefile rename commands/{simple => rlogin}/rlogin.c (100%) delete mode 100755 commands/rlogind/build create mode 100644 commands/rmdir/Makefile rename commands/{simple => rmdir}/rmdir.c (100%) create mode 100644 commands/rotate/Makefile rename commands/{scripts => rotate}/rotate.sh (100%) mode change 100755 => 100644 create mode 100644 commands/rsh/Makefile rename commands/{simple => rsh}/rsh.c (100%) create mode 100644 commands/rshd/Makefile rename commands/{simple/in.rshd.c => rshd/rshd.c} (100%) create mode 100644 commands/screendump/Makefile rename commands/{ibm => screendump}/screendump.c (100%) delete mode 100644 commands/scripts/Makefile delete mode 100755 commands/scripts/build create mode 100644 commands/sdump/Makefile rename commands/{ibm => sdump}/sdump.c (96%) create mode 100644 commands/sed/Makefile rename commands/{simple => sed}/sed.c (100%) create mode 100644 commands/setup/Makefile rename commands/{scripts => setup}/setup.sh (100%) mode change 100755 => 100644 delete mode 100644 commands/sh/Makefile delete mode 100755 commands/sh/build delete mode 100644 commands/sh/sh.h delete mode 100644 commands/sh/sh1.c delete mode 100644 commands/sh/sh2.c delete mode 100644 commands/sh/sh3.c delete mode 100644 commands/sh/sh4.c delete mode 100644 commands/sh/sh5.c delete mode 100644 commands/sh/sh6.c create mode 100644 commands/shar/Makefile rename commands/{simple => shar}/shar.c (100%) delete mode 100644 commands/simple/Makefile delete mode 100755 commands/simple/build delete mode 100644 commands/simple/origmkfs.c create mode 100644 commands/size/Makefile rename commands/{simple => size}/size.c (100%) create mode 100644 commands/sleep/Makefile rename commands/{simple => sleep}/sleep.c (100%) create mode 100644 commands/slip/Makefile rename commands/{simple => slip}/slip.c (100%) create mode 100644 commands/sort/Makefile rename commands/{simple => sort}/sort.c (100%) create mode 100644 commands/spell/Makefile rename commands/{scripts => spell}/spell.sh (100%) mode change 100755 => 100644 create mode 100644 commands/split/Makefile rename commands/{simple => split}/split.c (100%) create mode 100644 commands/srccrc/Makefile rename commands/{scripts => srccrc}/srccrc.sh (100%) mode change 100755 => 100644 create mode 100644 commands/stat/Makefile rename commands/{simple => stat}/stat.c (100%) create mode 100644 commands/strings/Makefile rename commands/{simple => strings}/strings.c (100%) create mode 100644 commands/strip/Makefile rename commands/{simple => strip}/strip.c (100%) create mode 100644 commands/stty/Makefile rename commands/{simple => stty}/stty.c (100%) create mode 100644 commands/su/Makefile rename commands/{simple => su}/su.c (100%) create mode 100644 commands/sum/Makefile rename commands/{simple => sum}/sum.c (100%) create mode 100644 commands/svclog/Makefile rename commands/{scripts => svclog}/svclog.sh (100%) mode change 100755 => 100644 create mode 100644 commands/swapfs/Makefile rename commands/{simple => swapfs}/swapfs.c (100%) create mode 100644 commands/sync/Makefile rename commands/{simple => sync}/sync.c (100%) create mode 100644 commands/synctree/Makefile rename commands/{simple => synctree}/synctree.c (100%) create mode 100644 commands/sysenv/Makefile rename commands/{simple => sysenv}/sysenv.c (100%) delete mode 100644 commands/syslogd/syslog.c delete mode 100644 commands/syslogd/syslog_test.c create mode 100644 commands/tail/Makefile rename commands/{simple => tail}/tail.c (100%) delete mode 100755 commands/talk/build delete mode 100755 commands/talkd/build create mode 100644 commands/tcpd/Makefile rename commands/{simple => tcpd}/tcpd.c (100%) create mode 100644 commands/tcpdp/Makefile create mode 100644 commands/tcpdp/tcpd.c create mode 100644 commands/tcpstat/Makefile rename commands/{simple => tcpstat}/tcpstat.c (100%) create mode 100644 commands/tee/Makefile rename commands/{simple => tee}/tee.c (100%) delete mode 100755 commands/telnet/build delete mode 100755 commands/telnetd/build create mode 100644 commands/term/Makefile rename commands/{simple => term}/term.c (100%) create mode 100644 commands/termcap/Makefile rename commands/{simple => termcap}/termcap.c (100%) create mode 100644 commands/tget/Makefile rename commands/{simple => tget}/tget.c (100%) create mode 100644 commands/time/Makefile rename commands/{simple => time}/time.c (100%) create mode 100644 commands/tinyhalt/Makefile create mode 100644 commands/tinyhalt/README rename commands/{reboot => tinyhalt}/tinyhalt.c (100%) create mode 100644 commands/top/Makefile rename commands/{simple => top}/top.c (99%) create mode 100644 commands/touch/Makefile rename commands/{simple => touch}/touch.c (100%) create mode 100644 commands/tr/Makefile rename commands/{simple => tr}/str.c (100%) rename commands/{simple => tr}/tr.c (100%) rename commands/{simple => tr}/tr.h (100%) create mode 100644 commands/truncate/Makefile rename commands/{simple => truncate}/truncate.c (100%) create mode 100644 commands/tsort/Makefile rename commands/{simple => tsort}/tsort.c (100%) create mode 100644 commands/ttt/Makefile rename commands/{simple => ttt}/ttt.c (100%) create mode 100644 commands/tty/Makefile rename commands/{simple => tty}/tty.c (100%) create mode 100644 commands/udpstat/Makefile rename commands/{simple => udpstat}/udpstat.c (100%) create mode 100644 commands/umount/Makefile rename commands/{simple => umount}/umount.c (100%) create mode 100644 commands/uname/Makefile rename commands/{simple => uname}/uname.c (100%) create mode 100644 commands/unexpand/Makefile rename commands/{simple => unexpand}/unexpand.c (100%) create mode 100644 commands/uniq/Makefile rename commands/{simple => uniq}/uniq.c (100%) create mode 100644 commands/unstack/Makefile rename commands/{scripts => unstack}/unstack.sh (100%) create mode 100644 commands/update/Makefile rename commands/{simple => update}/update.c (100%) delete mode 100755 commands/urlget/build create mode 100644 commands/uud/Makefile rename commands/{simple => uud}/uud.c (100%) create mode 100644 commands/uue/Makefile rename commands/{simple => uue}/uue.c (100%) create mode 100644 commands/version/Makefile rename commands/{scripts => version}/version.sh (100%) create mode 100644 commands/vol/Makefile rename commands/{simple => vol}/vol.c (100%) create mode 100644 commands/wc/Makefile rename commands/{simple => wc}/wc.c (100%) create mode 100644 commands/whatis/Makefile rename commands/{scripts => whatis}/whatis.sh (100%) mode change 100755 => 100644 create mode 100644 commands/whereis/Makefile rename commands/{scripts => whereis}/whereis.sh (100%) mode change 100755 => 100644 create mode 100644 commands/which/Makefile rename commands/{simple => which}/which.c (100%) create mode 100644 commands/who/Makefile rename commands/{simple => who}/who.c (100%) create mode 100644 commands/whoami/Makefile rename commands/{simple => whoami}/whoami.c (100%) create mode 100644 commands/write/Makefile rename commands/{simple => write}/write.c (100%) create mode 100644 commands/writeisofs/Makefile rename commands/{simple => writeisofs}/writeisofs.c (100%) create mode 100644 commands/xargs/Makefile rename commands/{simple => xargs}/xargs.c (100%) rename commands/{byacc/ACKNOWLEDGEMEN => yacc/ACKNOWLEDGEMENTS} (100%) create mode 100644 commands/yacc/Makefile rename commands/{byacc => yacc}/NEW_FEATURES (100%) create mode 100644 commands/yacc/NOTES rename commands/{byacc => yacc}/README (100%) rename commands/{byacc => yacc}/closure.c (55%) rename commands/{byacc => yacc}/defs.h (54%) rename commands/{byacc => yacc}/error.c (57%) rename commands/{byacc => yacc}/lalr.c (65%) rename commands/{byacc => yacc}/lr0.c (65%) create mode 100644 commands/yacc/main.c rename commands/{byacc => yacc}/mkpar.c (52%) rename commands/{byacc => yacc}/output.c (77%) rename commands/{byacc => yacc}/reader.c (80%) rename commands/{byacc => yacc}/skeleton.c (59%) create mode 100644 commands/yacc/symtab.c create mode 100644 commands/yacc/test/error.output create mode 100644 commands/yacc/test/error.tab.c create mode 100644 commands/yacc/test/error.tab.h create mode 100644 commands/yacc/test/error.y create mode 100644 commands/yacc/test/ftp.output create mode 100644 commands/yacc/test/ftp.tab.c create mode 100644 commands/yacc/test/ftp.tab.h create mode 100644 commands/yacc/test/ftp.y rename commands/{byacc => yacc}/verbose.c (60%) create mode 100644 commands/yacc/warshall.c create mode 100644 commands/yacc/yacc.1 delete mode 100755 commands/yap/build create mode 100644 commands/yes/Makefile rename commands/{simple => yes}/yes.c (100%) create mode 100644 commands/zdump/Makefile create mode 100644 commands/zic/Makefile delete mode 100755 commands/zmodem/build delete mode 120000 commands/zoneinfo/newctime.3 delete mode 120000 commands/zoneinfo/newstrftime.3 delete mode 120000 commands/zoneinfo/newtzset.3 delete mode 120000 commands/zoneinfo/time2posix.3 delete mode 120000 commands/zoneinfo/tzfile.5 delete mode 120000 commands/zoneinfo/tzselect.8 delete mode 120000 commands/zoneinfo/zdump.8 delete mode 120000 commands/zoneinfo/zic.8 create mode 100644 include/sys/cdefs.h create mode 100644 lib/libbz2/Makefile rename {man/man1 => lib/libc/stdtime}/date.1 (100%) rename {commands/zoneinfo => lib/libc/stdtime}/date.c (100%) rename {commands/zoneinfo => lib/libc/stdtime}/difftime.c (100%) rename {commands/zoneinfo => lib/libc/stdtime}/ialloc.c (100%) rename {commands/zoneinfo => lib/libc/stdtime}/logwtmp.c (100%) rename {commands/zoneinfo => lib/libc/stdtime}/private.h (100%) rename {commands/zoneinfo => lib/libc/stdtime}/scheck.c (100%) rename {commands/zoneinfo => lib/libc/stdtime}/tzfile.h (100%) rename {man/man8 => lib/libc/stdtime}/zdump.8 (100%) rename {commands/zoneinfo => lib/libc/stdtime}/zdump.c (100%) rename {man/man8 => lib/libc/stdtime}/zic.8 (100%) rename {commands/zoneinfo => lib/libc/stdtime}/zic.c (100%) create mode 100644 lib/libl/Makefile delete mode 100644 man/man1/flex.1 delete mode 100644 man/man1/ftp.1 delete mode 100644 man/man1/yacc.1 delete mode 100644 man/man8/tzselect.8 create mode 100644 share/Makefile create mode 100644 share/zoneinfo/Makefile rename commands/zoneinfo/Makefile => share/zoneinfo/Makefile.orig (100%) rename {commands => share}/zoneinfo/README (100%) rename {commands => share}/zoneinfo/Theory (100%) rename {commands => share}/zoneinfo/africa (100%) rename {commands => share}/zoneinfo/antarctica (100%) rename {commands => share}/zoneinfo/asia (100%) rename {commands => share}/zoneinfo/australasia (100%) rename {commands => share}/zoneinfo/backward (100%) rename {commands => share}/zoneinfo/checktab.awk (100%) rename {commands => share}/zoneinfo/etcetera (100%) rename {commands => share}/zoneinfo/europe (100%) rename {commands => share}/zoneinfo/factory (100%) rename {commands => share}/zoneinfo/iso3166.tab (100%) rename {commands => share}/zoneinfo/itca.jpg (100%) rename {commands => share}/zoneinfo/leapseconds (100%) rename {commands => share}/zoneinfo/northamerica (100%) rename {commands => share}/zoneinfo/pacificnew (100%) rename {commands => share}/zoneinfo/solar87 (100%) rename {commands => share}/zoneinfo/solar88 (100%) rename {commands => share}/zoneinfo/solar89 (100%) rename {commands => share}/zoneinfo/southamerica (100%) rename {commands => share}/zoneinfo/systemv (100%) rename {commands => share}/zoneinfo/tz-art.htm (100%) rename {commands => share}/zoneinfo/tz-link.htm (100%) rename {commands => share}/zoneinfo/tzselect.ksh (100%) rename {commands => share}/zoneinfo/usno1988 (100%) rename {commands => share}/zoneinfo/usno1989 (100%) rename {commands => share}/zoneinfo/usno1989a (100%) rename {commands => share}/zoneinfo/usno1995 (100%) rename {commands => share}/zoneinfo/usno1997 (100%) rename {commands => share}/zoneinfo/usno1998 (100%) rename {commands => share}/zoneinfo/workman.sh (100%) rename {commands => share}/zoneinfo/yearistype.sh (100%) rename {commands => share}/zoneinfo/zone.tab (100%) diff --git a/Makefile b/Makefile index 9e407d91c..7e4dbd2d9 100644 --- a/Makefile +++ b/Makefile @@ -53,6 +53,8 @@ commands: cd commands && $(MAKE) all depend:: + cd boot && $(MAKE) $@ + cd commands && $(MAKE) $@ cd kernel && $(MAKE) $@ cd servers && $(MAKE) $@ cd drivers && $(MAKE) $@ @@ -71,6 +73,7 @@ install:: cd boot && $(MAKE) all install cd man && $(MAKE) all install makedb cd commands && $(MAKE) all install + cd share && $(MAKE) all install cd tools && $(MAKE) all install cd servers && $(MAKE) all install cd drivers && $(MAKE) all install diff --git a/boot/Makefile b/boot/Makefile index 7c525438e..e40aadfb1 100644 --- a/boot/Makefile +++ b/boot/Makefile @@ -1,118 +1,75 @@ # Makefile for the boot monitor package. -SYS = .. +PROGS= bootblock cdbootblock bootexec boot masterboot \ + jumpboot installboot edparams -CC = exec cc -CC86 = exec cc -mi86 -Was-ncc -CFLAGS = -I$(SYS) -LIBS = -lsys -LD = $(CC) -s -.o -LD86 = $(CC86) -.o -BIN = /usr/bin -MDEC = /usr/mdec +SRCS.bootblock= bootblock.s +CPPFLAGS.bootblock.s= ${I86CPPFLAGS} +LDFLAGS.bootblock= ${I86LDFLAGS} +BINDIR.bootblock= /usr/mdec +MAN.bootblock= -all: bootblock cdbootblock boot edparams masterboot jumpboot installboot addaout -dos: boot.com mkfile.com +SRCS.cdbootblock= cdbootblock.s +CPPFLAGS.cdbootblock.s= ${I86CPPFLAGS} -DCDBOOT +LDFLAGS.cdbootblock= ${I86LDFLAGS} +BINDIR.cdbootblock= /usr/mdec +MAN.cdbootblock= -bootblock: bootblock.s - $(LD86) -com -o $@ bootblock.s +SRCS.bootexec= boothead.s boot.c bootimage.c rawfs86.c +CPPFLAGS.boothead.s= ${I86CPPFLAGS} +CPPFLAGS.boot.c= ${I86CPPFLAGS} +CPPFLAGS.bootimage.c= ${I86CPPFLAGS} +CPPFLAGS.rawfs86.c= ${I86CPPFLAGS} +LDFLAGS.bootexec= ${I86LDFLAGS} +DPADD.bootexec= ${LIBSYS} +LDADD.bootexec= -lsys +BINDIR.bootexec= /usr/mdec +MAN.bootexec= -cdbootblock: bootblock.s - $(LD86) -com -o $@ bootblock.s -DCDBOOT +BINDIR.boot= /usr/mdec +MAN.boot= -masterboot: masterboot.s - $(LD86) -com -o $@ masterboot.s +SRCS.masterboot= masterboot.s +CPPFLAGS.masterboot.s= ${I86CPPFLAGS} +LDFLAGS.masterboot= ${I86LDFLAGS} +BINDIR.masterboot= /usr/mdec +MAN.masterboot= -jumpboot: jumpboot.s - $(LD86) -com -o $@ jumpboot.s +SRCS.jumpboot= jumpboot.s +CPPFLAGS.jumpboot.s= ${I86CPPFLAGS} +LDFLAGS.jumpboot= ${I86LDFLAGS} +BINDIR.jumpboot= /usr/mdec +MAN.jumpboot= -boot.o: boot.c - $(CC86) $(CFLAGS) -c boot.c +SRCS.installboot= installboot.c rawfs.c +BINDIR.installboot= /usr/bin +MAN.installboot= -bootimage.o: bootimage.c - $(CC86) $(CFLAGS) -c bootimage.c +SRCS.edparams= edparams.c rawfs.c +CPPFLAGS.edparams.c= -DUNIX +BINDIR.edparams= /usr/bin +MAN.edparams= -rawfs86.o: rawfs.c rawfs.o +rawfs86.c: rawfs.c ln -f rawfs.c rawfs86.c - $(CC86) $(CFLAGS) -c rawfs86.c - rm rawfs86.c - -cmp -s rawfs.o rawfs86.o && ln -f rawfs.o rawfs86.o -boot: boothead.s boot.o bootimage.o rawfs86.o - $(LD86) -o boot boothead.s boot.o bootimage.o rawfs86.o $(LIBS) - install -S 22kb boot - -edparams.o: boot.c +edparams.c: boot.c ln -f boot.c edparams.c - $(CC) $(CFLAGS) -DUNIX -c edparams.c - rm edparams.c -edparams: edparams.o rawfs.o - $(CC) $(CFLAGS) $(STRIP) -o $@ edparams.o rawfs.o - install -S 16kw edparams +cdbootblock.s: bootblock.s + ln -f bootblock.s cdbootblock.s -dosboot.o: boot.c - $(CC86) $(CFLAGS) -DDOS -o $@ -c boot.c +boot: bootexec + install -S 22kb bootexec + cp bootexec boot -doshead.o: doshead.s - $(CC) -mi386 -o $@ -c doshead.s +CPPFLAGS= -I${MINIXSRCDIR} +AFLAGS= -I${MINIXSRCDIR} +I86CPPFLAGS= -mi86 -Was-ncc +I86LDFLAGS= -mi86 -Was-ncc -.o -com -dosboot: doshead.o dosboot.o bootimage.o rawfs86.o - $(LD86) -com -o $@ \ - doshead.o dosboot.o bootimage.o rawfs86.o $(LIBS) +STRIPFLAG= -s -boot.com: dosboot - exec sh a.out2com dosboot boot.com +CLEANFILES+= rawfs86.c edparams.c cdbootblock.s -mkfile: mkfhead.s mkfile.c - $(LD) -.o -mi86 -com -o $@ mkfhead.s mkfile.c $(LIBS) - -mkfile.com: mkfile - exec sh a.out2com mkfile mkfile.com - -installboot: installboot.o rawfs.o - $(CC) $(STRIP) -o installboot installboot.o rawfs.o - install -S 6kw installboot - -addaout: addaout.o - $(CC) -o addaout addaout.o - -installboot.o bootimage.o: image.h -boot.o bootimage.o dosboot.o edparams.o: boot.h -rawfs.o rawfs86.o installboot.o boot.o bootimage.o: rawfs.h - -install: $(MDEC)/bootblock $(MDEC)/boot $(MDEC)/masterboot \ - $(MDEC)/jumpboot $(BIN)/installboot $(BIN)/edparams -dosinstall: $(MDEC)/boot.com $(MDEC)/mkfile.com - -$(MDEC)/bootblock: bootblock - install -cs -o bin -m 644 $? $@ - -$(MDEC)/boot: boot - install -cs -o bin -m 644 $? $@ - -$(MDEC)/boot.com: boot.com - install -c -m 644 $? $@ - -$(MDEC)/mkfile.com: mkfile.com - install -c -m 644 $? $@ - -$(MDEC)/masterboot: masterboot - install -cs -o bin -m 644 $? $@ - -$(MDEC)/jumpboot: jumpboot - install -cs -o bin -m 644 $? $@ - -$(BIN)/installboot: installboot - install -cs -o bin $? $@ - -$(BIN)/addaout: addaout - install -cs -o bin $? $@ - -$(BIN)/edparams: edparams - install -cs -o bin $? $@ - -clean: - rm -f *.bak *.o - rm -f cdbootblock bootblock addaout installboot boot masterboot jumpboot edparams - rm -f dosboot boot.com mkfile mkfile.com +.include diff --git a/commands/scripts/DESCRIBE.sh b/commands/DESCRIBE/DESCRIBE.sh old mode 100755 new mode 100644 similarity index 100% rename from commands/scripts/DESCRIBE.sh rename to commands/DESCRIBE/DESCRIBE.sh diff --git a/commands/DESCRIBE/Makefile b/commands/DESCRIBE/Makefile new file mode 100644 index 000000000..5a94fc6b1 --- /dev/null +++ b/commands/DESCRIBE/Makefile @@ -0,0 +1,4 @@ +SCRIPTS= DESCRIBE.sh +MAN= + +.include diff --git a/commands/scripts/M.sh b/commands/M/M.sh old mode 100755 new mode 100644 similarity index 100% rename from commands/scripts/M.sh rename to commands/M/M.sh diff --git a/commands/M/Makefile b/commands/M/Makefile new file mode 100644 index 000000000..43ea0d6ac --- /dev/null +++ b/commands/M/Makefile @@ -0,0 +1,7 @@ +SCRIPTS= M.sh +BINDIR= /bin +MAN= + +LINKS+= ${BINDIR}/M ${BINDIR}/U + +.include diff --git a/commands/scripts/MAKEDEV.sh b/commands/MAKEDEV/MAKEDEV.sh old mode 100755 new mode 100644 similarity index 100% rename from commands/scripts/MAKEDEV.sh rename to commands/MAKEDEV/MAKEDEV.sh diff --git a/commands/MAKEDEV/Makefile b/commands/MAKEDEV/Makefile new file mode 100644 index 000000000..fa8241785 --- /dev/null +++ b/commands/MAKEDEV/Makefile @@ -0,0 +1,4 @@ +SCRIPTS= MAKEDEV.sh +MAN= + +.include diff --git a/commands/Makefile b/commands/Makefile index c628cd144..58c705ada 100644 --- a/commands/Makefile +++ b/commands/Makefile @@ -1,31 +1,44 @@ # Makefile for commands. -MAKE = exec make -$(MAKEFLAGS) -BZIP2=bzip2-1.0.3 -FLEX=flex-2.5.4 +.include -SMALLPROGRAMS=`arch` aal advent ash autil awk byacc cawf cron de dhcpd dis88 elle elvis ftp101 ftpd200 ibm indent m4 make mdb mined patch pax profile ps reboot rlogind scripts sh simple syslogd swifi talk talkd telnet telnetd urlget yap zoneinfo - -usage: - @echo "Usage: make all # Compile all commands" >&2 - @echo " make install # Install the result (run as bin!)" >&2 - @echo " make clean # Delete .o files and other junk" >&2 - -all: - cd zmodem && make - cd $(BZIP2) && /bin/sh build build - set -e; for p in $(SMALLPROGRAMS); do ( cd $$p && make all ); done - -install: - set -e; for p in $(SMALLPROGRAMS); do ( cd $$p && make install ); done - cd zmodem && make install - cd $(BZIP2) && make install - cd $(FLEX) && sh build - -clean:: - cd $(BZIP2) && make clean - cd zmodem && make clean - if [ -f $(FLEX)/Makefile ]; then cd $(FLEX) && make distclean ; fi - for p in $(SMALLPROGRAMS); do ( cd $$p && make clean ); done +SUBDIR= aal add_route adduser advent arp ash at autil awk \ + backup badblocks banner basename bigmake binpackage \ + binpackages binsizes bzip2 bzip2recover cal calendar \ + cat cawf cd cdiff cdprobe cgrep checkhier chmem \ + chmod chown chroot ci cksum cleantmp clear cmp co \ + comm compress cp crc cron crontab cut datasizes date \ + dd de decomp16 DESCRIBE dev2name devsize df dhcpd \ + dhrystone diff dirname dis88 du dumpcore easypack \ + ed eject elle elvis env expand factor fgrep file \ + find finger fingerd fix fold format fortune fsck \ + fsck1 ftp101 ftpd200 getty gomoku grep head host \ + hostaddr id ifconfig ifdef indent install \ + intr ipcrm ipcs irdpd isoread join kill last leave \ + lex life loadkeys loadramdisk logger login look lp \ + lpd ls lspci M m4 mail make MAKEDEV makewhatis man \ + mdb mesg mined mkdep mkdir mkdist mkfifo mkfs mknod \ + mkproto modem mount mt netconf newroot nice nm nohup \ + nonamed od packit packman passwd paste patch pax \ + ping postinstall poweroff pr prep printf printroot \ + profile progressbar proto pr_routes ps pwd pwdauth \ + ramdisk rarpd rawspeed rcp rdate readall readclock \ + readfs reboot remsync rev rget rlogin rlogind rmdir \ + rotate rsh rshd sed setup shar size \ + sleep slip sort spell split srccrc stat strings strip \ + stty su sum svclog swapfs swifi sync synctree sysenv \ + syslogd tail talk talkd tcpd tcpdp tcpstat tee telnet \ + telnetd term termcap tget time tinyhalt top touch tr \ + truncate tsort ttt tty udpstat umount uname unexpand \ + uniq unstack update urlget uud uue version vol wc \ + whatis whereis which who whoami write writeisofs \ + xargs yacc yap yes zdump zic zmodem +.if ${ARCH} == "i386" +SUBDIR+= atnormalize dosread fdisk loadfont \ + mixer autopart part partition playwave postmort \ + recwave repartition screendump +SUBDIR+= acd asmconv gas2ack +.endif +.include diff --git a/commands/Makefile.inc b/commands/Makefile.inc new file mode 100644 index 000000000..07b38a6ae --- /dev/null +++ b/commands/Makefile.inc @@ -0,0 +1,2 @@ +CPPFLAGS+= -D_MINIX -D_POSIX_SOURCE +BINDIR?=/usr/bin diff --git a/commands/aal/Makefile b/commands/aal/Makefile index 0931a021c..26cf974be 100644 --- a/commands/aal/Makefile +++ b/commands/aal/Makefile @@ -1,56 +1,12 @@ # Makefile for aal -CC=exec cc -CFLAGS=-I. -wo -DAAL -DSTB -DNDEBUG -DDISTRIBUTION -D_POSIX_SOURCE -D_MINIX -LDFLAGS=-i +PROG= aal +SRCS= archiver.c print.c rd.c rd_arhdr.c rd_unsig2.c sprint.c \ + wr_arhdr.c wr_bytes.c wr_int2.c wr_long.c wr_ranlib.c \ + format.c rd_bytes.c system.c write.c long2str.c +CPPFLAGS+= -I${.CURDIR} -wo -DAAL -DSTB -DNDEBUG -DDISTRIBUTION -all: aal +LINKS+= ${BINDIR}/aal ${BINDIR}/ar +MAN= -OFILES= archiver.o \ - print.o \ - rd.o \ - rd_arhdr.o \ - rd_unsig2.o \ - sprint.o \ - wr_arhdr.o \ - wr_bytes.o \ - wr_int2.o \ - wr_long.o \ - wr_ranlib.o \ - format.o \ - rd_bytes.o \ - system.o \ - write.o \ - long2str.o - -aal: $(OFILES) - $(CC) $(LDFLAGS) -o aal $(OFILES) - install -S 512k $@ - -install: /usr/bin/aal /usr/bin/ar - -/usr/bin/aal: aal - install -cs -o bin aal $@ - -/usr/bin/ar: /usr/bin/aal - install -l h $? $@ - -archiver.o: -print.o: -rd.o: -rd_arhdr.o: -rd_unsig2.o: -sprint.o: -wr_arhdr.o: -wr_bytes.o: -wr_int2.o: -wr_long.o: -wr_ranlib.o: -format.o: -rd_bytes.o: -system.o: -write.o: -long2str.o: - -clean: - rm -f *.o core *.bak aal +.include diff --git a/commands/aal/build b/commands/aal/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/aal/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/acd/Makefile b/commands/acd/Makefile new file mode 100644 index 000000000..91ff91055 --- /dev/null +++ b/commands/acd/Makefile @@ -0,0 +1,13 @@ +# Makefile for acd + +.include + +PROG= acd +CPPFLAGS+= -DARCH=\"`arch`\" -DDESCR=\"/usr/lib/descr\" +LINKS+= ${BINDIR}/acd ${BINDIR}/cc +FILESDIR= /usr/lib +FILES= acd.descr +FILESNAME= descr +MAN= + +.include diff --git a/commands/i386/acd.c b/commands/acd/acd.c similarity index 100% rename from commands/i386/acd.c rename to commands/acd/acd.c diff --git a/commands/i386/acd.descr b/commands/acd/acd.descr similarity index 100% rename from commands/i386/acd.descr rename to commands/acd/acd.descr diff --git a/commands/add_route/Makefile b/commands/add_route/Makefile new file mode 100644 index 000000000..79aa4e85b --- /dev/null +++ b/commands/add_route/Makefile @@ -0,0 +1,6 @@ +PROG= add_route +MAN= + +LINKS+= ${BINDIR}/add_route ${BINDIR}/del_route + +.include diff --git a/commands/simple/add_route.c b/commands/add_route/add_route.c similarity index 100% rename from commands/simple/add_route.c rename to commands/add_route/add_route.c diff --git a/commands/adduser/Makefile b/commands/adduser/Makefile new file mode 100644 index 000000000..ea1214a0e --- /dev/null +++ b/commands/adduser/Makefile @@ -0,0 +1,4 @@ +SCRIPTS= adduser.sh +MAN= + +.include diff --git a/commands/scripts/adduser.sh b/commands/adduser/adduser.sh old mode 100755 new mode 100644 similarity index 100% rename from commands/scripts/adduser.sh rename to commands/adduser/adduser.sh diff --git a/commands/advent/Makefile b/commands/advent/Makefile index aff80c4f1..399acbebd 100644 --- a/commands/advent/Makefile +++ b/commands/advent/Makefile @@ -1,63 +1,28 @@ # Makefile for advent -# Where to put the adventure text files, and the binary executable. -# Need the trailing "/"s. -TEXTDIR = /usr/lib/advent/ -BINDIR = /usr/bin +PROG= advent +SRCS= advent.c database.c english.c initial.c itverb.c score.c \ + travel.c turn.c utility.c verb.c vocab.c -# Flags you may want to add to CFLAGS: -# -DHAS_STDC=0 or 1 We have Standard C. Default=1 iff __STDC__ is nonzero. +# Where to put the adventure text files +# Need the trailing "/" on TEXTDIR +TEXTDIR= /usr/lib/advent/ +FILESDIR= ${TEXTDIR} +DATFILES= advent1.dat advent2.dat advent3.dat advent4.dat +FILES= ${DATFILES} +MAN= -CC = exec cc -CFLAGS = -D_POSIX_SOURCE -LDFLAGS = -i - -OBJS = advent.o database.o english.o initial.o itverb.o score.o\ - travel.o turn.o utility.o verb.o vocab.o - -DAT = advent1.dat advent2.dat advent3.dat advent4.dat -INSTDAT = $(TEXTDIR)advent1.dat $(TEXTDIR)advent2.dat \ - $(TEXTDIR)advent3.dat $(TEXTDIR)advent4.dat - -all: $(DAT) advent - -install: $(TEXTDIR) $(INSTDAT) $(BINDIR)/advent - -$(TEXTDIR): - install -d -o bin $(TEXTDIR) - -$(TEXTDIR)advent1.dat: advent1.dat - install -c -o bin $? $@ - -$(TEXTDIR)advent2.dat: advent2.dat - install -c -o bin $? $@ - -$(TEXTDIR)advent3.dat: advent3.dat - install -c -o bin $? $@ - -$(TEXTDIR)advent4.dat: advent4.dat - install -c -o bin $? $@ - -$(BINDIR)/advent: advent - install -cs -o bin $? $@ - -advent: $(OBJS) - $(CC) $(LDFLAGS) -o advent $(OBJS) +database.o: advtext.h setup: setup.c advent.h - $(CC) $(CFLAGS) $(LDFLAGS) -o setup setup.c - + ${CC} ${CPPFLAGS} ${LDFLAGS} -o setup setup.c + advtext.h advent1.dat advent2.dat advent3.dat advent4.dat: \ setup advent1.txt advent2.txt advent3.txt advent4.txt ./setup -advent.o: advent.h advdec.h advent.c - $(CC) -c $(CFLAGS) -DTEXTDIR='"$(TEXTDIR)"' advent.c +CPPFLAGS.advent.c= -DTEXTDIR='"${TEXTDIR}"' -database.o: advent.h advdec.h advtext.h -travel.o: advent.h advdec.h advcave.h -initial.o english.o itverb.o score.o turn.o utility.o\ - verb.o vocab.o: advent.h advdec.h +CLEANFILES+= ${DATFILES} advtext.h setup -clean: - @rm -f *.o *.BAK *.dat advtext.h core advent setup +.include diff --git a/commands/advent/build b/commands/advent/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/advent/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/arp/Makefile b/commands/arp/Makefile new file mode 100644 index 000000000..48165be3d --- /dev/null +++ b/commands/arp/Makefile @@ -0,0 +1,5 @@ +PROG= arp +BINMODE= 4755 +MAN= + +.include diff --git a/commands/simple/arp.c b/commands/arp/arp.c similarity index 100% rename from commands/simple/arp.c rename to commands/arp/arp.c diff --git a/commands/ash/Makefile b/commands/ash/Makefile index 71768f9f7..f9e05c17e 100644 --- a/commands/ash/Makefile +++ b/commands/ash/Makefile @@ -1,33 +1,34 @@ # Makefile for ash. -SRCS= alias.c builtins.c cd.c error.c eval.c exec.c expand.c histedit.c \ - input.c \ - jobs.c mail.c main.c memalloc.c miscbltin.c mystring.c nodes.c \ - options.c parser.c redir.c setmode.c show.c signames.c syntax.c \ - trap.c \ - output.c var.c +.include -OBJS= alias.o builtins.o cd.o error.o eval.o exec.o expand.o histedit.o \ - input.o \ - jobs.o mail.o main.o memalloc.o miscbltin.o mystring.o nodes.o \ - options.o parser.o redir.o setmode.o show.o signames.o syntax.o \ - trap.o \ - output.o var.o init.o \ - bltin/echo.o bltin/expr.o bltin/operators.o bltin/regexp.o \ - arith.o arith_lex.o +YHEADER=1 +PROG= sh -LEX=flex -YACC=/usr/bin/yacc -.c.o: - $(CC) $(CFLAGS) -c $< -o $@ +SHSRCS= alias.c arith.y arith_lex.l cd.c echo.c error.c eval.c exec.c expand.c \ + histedit.c input.c jobs.c mail.c main.c memalloc.c miscbltin.c \ + mystring.c options.c output.c parser.c redir.c show.c \ + trap.c var.c setmode.c expr.c regexp.c +GENSRCS= builtins.c init.c nodes.c syntax.c operators.c signames.c +GENHDRS= builtins.h nodes.h syntax.h token.h operators.h signames.h +SRCS= ${SHSRCS} ${GENSRCS} +DPSRCS+=${GENHDRS} +BINDIR= /bin +MAN= + +DPADD+= ${LIBL} ${LIBEDIT} +LDADD+= -ll -ledit + +LFLAGS= -8 # 8-bit lex scanner for arithmetic +YFLAGS= -d + +# The .depend file can get references to these temporary files +.OPTIONAL: lex.yy.c y.tab.c # Enable this line to disable command line editing #EDIT=-DNO_HISTORY # Enable this line to use the editline library instead of libedit EDIT=-DEDITLINE -EDITLIB=-ledit - -FLEXLIB=-lfl # Enable this line if your system does not have a NO_PATHS_H=-DNO_PATHS_H @@ -36,91 +37,50 @@ NO_PATHS_H=-DNO_PATHS_H NO_JOBS=-DJOBS=0 MKB_NO_JOBS=-j -CPPFLAGS= -DSHELL -I. -D_MINIX $(EDIT) $(NO_PATHS_H) $(NO_JOBS) -CFLAGS= $(OPT) $(CPPFLAGS) -LIBS= $(EDITLIB) $(FLEXLIB) +CPPFLAGS+=-DSHELL -I. -I${.CURDIR} +CPPFLAGS+=${EDIT} ${NO_PATHS_H} ${NO_JOBS} -CLEANFILES= $(OBJS) \ - arith.c arith_y.h arith_lex.c builtins.c builtins.h init.c \ - mkinit mknodes mksignames mksyntax \ - nodes.c nodes.h signames.c signames.h syntax.c syntax.h token.h \ - bltin/operators.h bltin/operators.c +.PATH: ${.CURDIR}/bltin -all: sh +CLEANFILES+= mkinit mkinit.o mknodes mknodes.o \ + mksyntax mksyntax.o mksignames mksignames.o +CLEANFILES+= ${GENSRCS} ${GENHDRS} y.tab.h -sh: $(OBJS) - $(CC) $(CFLAGS) -fnone -o sh $(OBJS) $(LIBS) - install -S 136k sh +build-tools: mkinit mknodes mksyntax mksignames -install: /usr/bin/ash /usr/bin/sh /bin/sh /bin/bigsh +.ORDER: builtins.c builtins.h +builtins.c builtins.h: mkbuiltins builtins.def shell.h + cd ${.CURDIR}; sh mkbuiltins ${MKB_NO_JOBS} ${.OBJDIR} shell.h builtins.def -/usr/bin/ash: sh - install -cs -o bin $> $@ +init.c: mkinit alias.c eval.c exec.c input.c jobs.c options.c parser.c \ + redir.c trap.c var.c + ./mkinit ${.ALLSRC:S/^mkinit$//} -/usr/bin/sh: /usr/bin/ash - install -l h $> $@ - -/bin/sh: /usr/bin/ash - install -l h -cs $> $@ - -/bin/bigsh: /usr/bin/ash - install -S 6600k -l h -cs $> $@ - -clean: - rm -f $(CLEANFILES) sh core - -parser.o: token.def - -token.def: mktokens - sh mktokens - -arith.c: arith.y - $(YACC) -d $< - mv y.tab.c $@ - mv y.tab.h arith_y.h - -arith_lex.c: arith_lex.l - -builtins.c builtins.h: builtins.def shell.h - sh mkbuiltins $(MKB_NO_JOBS) . shell.h builtins.def - -init.c: mkinit $(SRCS) - ./mkinit $(SRCS) - -mkinit: mkinit.c - $(CC) $(CFLAGS) mkinit.c -o $@ +mkinit: mkinit.o +mknodes: mknodes.o +mksyntax: mksyntax.o +mksignames: mksignames.o +.ORDER: nodes.c nodes.h nodes.c nodes.h: mknodes nodetypes nodes.c.pat - ./mknodes nodetypes nodes.c.pat - -mknodes: mknodes.c - $(CC) $(CFLAGS) mknodes.c -o $@ - -signames.c signames.h: mksignames - ./mksignames - -mksignames: mksignames.c - $(CC) $(CFLAGS) mksignames.c -o $@ + ./mknodes ${.CURDIR}/nodetypes ${.CURDIR}/nodes.c.pat +.ORDER: syntax.c syntax.h syntax.c syntax.h: mksyntax ./mksyntax -mksyntax: mksyntax.c parser.h - $(CC) $(CFLAGS) mksyntax.c -o $@ +token.h: mktokens + sh ${.CURDIR}/mktokens -bltin/operators.h: bltin/mkexpr bltin/unary_op bltin/binary_op - cd bltin && sh mkexpr unary_op binary_op +.ORDER: signames.c signames.h +signames.c signames.h: mksignames + ./mksignames -bltin/operators.c: bltin/mkexpr bltin/unary_op bltin/binary_op - cd bltin && sh mkexpr unary_op binary_op +.ORDER: operators.c operators.h +operators.c operators.h: mkexpr unary_op binary_op + sh bltin/mkexpr bltin/unary_op bltin/binary_op -# Dependencies you say? This will have to do. -$(OBJS): error.h eval.h exec.h expand.h init.h input.h \ - jobs.h machdep.h mail.h main.h memalloc.h mystring.h options.h \ - output.h parser.h redir.h shell.h trap.h var.h \ - builtins.h nodes.h signames.h syntax.h +arith.h: arith.c +arith.c: arith.y -bltin/expr.o bltin/operators.o: bltin/operators.h - -# -# $PchId: Makefile,v 1.4 2006/05/22 12:40:46 philip Exp $ +.include diff --git a/commands/ash/alias.c b/commands/ash/alias.c index 9f197ed6e..0d39732d3 100644 --- a/commands/ash/alias.c +++ b/commands/ash/alias.c @@ -49,7 +49,6 @@ __FBSDID("$FreeBSD: src/bin/sh/alias.c,v 1.18 2004/04/06 20:06:51 markm Exp $"); #include "mystring.h" #include "alias.h" #include "options.h" /* XXX for argptr (should remove?) */ -#include "builtins.h" #define ATABSIZE 39 diff --git a/commands/ash/arith.h b/commands/ash/arith.h deleted file mode 100644 index 90c0a6701..000000000 --- a/commands/ash/arith.h +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * Copyright (c) 1995 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)arith.h 1.1 (Berkeley) 5/4/95 - * $FreeBSD: src/bin/sh/arith.h,v 1.9 2004/04/06 20:06:51 markm Exp $ - */ - -int arith(char *); -int arith_assign(char *, arith_t); -int expcmd(int, char **); - -/* - * $PchId: arith.h,v 1.3 2006/03/31 11:25:25 philip Exp $ - */ diff --git a/commands/ash/arith.y b/commands/ash/arith.y index f20eb3287..50dfd5e29 100644 --- a/commands/ash/arith.y +++ b/commands/ash/arith.y @@ -42,12 +42,11 @@ __FBSDID("$FreeBSD: src/bin/sh/arith.y,v 1.19 2004/05/24 10:11:31 stefanf Exp $" */ #include -#include #include + #include "shell.h" -#include "arith.h" -#include "arith_lex.h" +#include "expand.h" #include "var.h" %} %union { @@ -261,7 +260,6 @@ expr: #include "error.h" #include "output.h" #include "memalloc.h" -#include "builtins.h" #define lstrlen(var) (3 + (2 + CHAR_BIT * sizeof((var))) / 3) @@ -360,7 +358,3 @@ error(char *s) exit(1); } #endif - -/* - * $PchId: arith.y,v 1.6 2006/05/22 12:41:47 philip Exp $ - */ diff --git a/commands/ash/arith_lex.l b/commands/ash/arith_lex.l index 6c5a3616f..57d71e966 100644 --- a/commands/ash/arith_lex.l +++ b/commands/ash/arith_lex.l @@ -44,8 +44,7 @@ __FBSDID("$FreeBSD: src/bin/sh/arith_lex.l,v 1.22 2004/04/06 20:06:51 markm Exp #include #include "shell.h" -#include "arith_lex.h" -#include "arith_y.h" +#include "arith.h" #include "error.h" #include "memalloc.h" #include "var.h" @@ -132,7 +131,3 @@ arith_lex_reset(void) { YY_NEW_FILE; } - -/* - * $PchId: arith_lex.l,v 1.5 2006/04/10 14:35:29 philip Exp $ - */ diff --git a/commands/ash/expand.h b/commands/ash/expand.h index 061d85f04..f53b61c9d 100644 --- a/commands/ash/expand.h +++ b/commands/ash/expand.h @@ -62,6 +62,13 @@ void rmescapes(char *); int casematch(union node *, char *); int wordexpcmd(int, char **); +/* From arith.y */ +int arith(char *); +int arith_assign(char *, arith_t); +int expcmd(int , char **); +void arith_lex_reset(void); + + /* * $PchId: expand.h,v 1.4 2006/03/30 14:50:52 philip Exp $ */ diff --git a/commands/asmconv/Makefile b/commands/asmconv/Makefile new file mode 100644 index 000000000..01dd6bc3d --- /dev/null +++ b/commands/asmconv/Makefile @@ -0,0 +1,8 @@ +# Makefile for asmconv. + +PROG= asmconv +SRCS= asm86.c asmconv.c parse_ack.c parse_gnu.c parse_bas.c \ + tokenize.c emit_ack.c emit_gnu.c +MAN= + +.include diff --git a/commands/i386/asmconv/asm86.c b/commands/asmconv/asm86.c similarity index 100% rename from commands/i386/asmconv/asm86.c rename to commands/asmconv/asm86.c diff --git a/commands/i386/asmconv/asm86.h b/commands/asmconv/asm86.h similarity index 100% rename from commands/i386/asmconv/asm86.h rename to commands/asmconv/asm86.h diff --git a/commands/i386/asmconv/asmconv.c b/commands/asmconv/asmconv.c similarity index 100% rename from commands/i386/asmconv/asmconv.c rename to commands/asmconv/asmconv.c diff --git a/commands/i386/asmconv/asmconv.h b/commands/asmconv/asmconv.h similarity index 100% rename from commands/i386/asmconv/asmconv.h rename to commands/asmconv/asmconv.h diff --git a/commands/i386/asmconv/emit_ack.c b/commands/asmconv/emit_ack.c similarity index 100% rename from commands/i386/asmconv/emit_ack.c rename to commands/asmconv/emit_ack.c diff --git a/commands/i386/asmconv/emit_gnu.c b/commands/asmconv/emit_gnu.c similarity index 100% rename from commands/i386/asmconv/emit_gnu.c rename to commands/asmconv/emit_gnu.c diff --git a/commands/i386/asmconv/languages.h b/commands/asmconv/languages.h similarity index 100% rename from commands/i386/asmconv/languages.h rename to commands/asmconv/languages.h diff --git a/commands/i386/asmconv/parse_ack.c b/commands/asmconv/parse_ack.c similarity index 100% rename from commands/i386/asmconv/parse_ack.c rename to commands/asmconv/parse_ack.c diff --git a/commands/i386/asmconv/parse_bas.c b/commands/asmconv/parse_bas.c similarity index 100% rename from commands/i386/asmconv/parse_bas.c rename to commands/asmconv/parse_bas.c diff --git a/commands/i386/asmconv/parse_gnu.c b/commands/asmconv/parse_gnu.c similarity index 100% rename from commands/i386/asmconv/parse_gnu.c rename to commands/asmconv/parse_gnu.c diff --git a/commands/i386/asmconv/syntax.ack b/commands/asmconv/syntax.ack similarity index 100% rename from commands/i386/asmconv/syntax.ack rename to commands/asmconv/syntax.ack diff --git a/commands/i386/asmconv/token.h b/commands/asmconv/token.h similarity index 100% rename from commands/i386/asmconv/token.h rename to commands/asmconv/token.h diff --git a/commands/i386/asmconv/tokenize.c b/commands/asmconv/tokenize.c similarity index 100% rename from commands/i386/asmconv/tokenize.c rename to commands/asmconv/tokenize.c diff --git a/commands/at/Makefile b/commands/at/Makefile new file mode 100644 index 000000000..a85b9a04a --- /dev/null +++ b/commands/at/Makefile @@ -0,0 +1,5 @@ +PROG= at +BINMODE= 4755 +MAN= + +.include diff --git a/commands/simple/at.c b/commands/at/at.c similarity index 100% rename from commands/simple/at.c rename to commands/at/at.c diff --git a/commands/atnormalize/Makefile b/commands/atnormalize/Makefile new file mode 100644 index 000000000..a3063b802 --- /dev/null +++ b/commands/atnormalize/Makefile @@ -0,0 +1,4 @@ +PROG= atnormalize +MAN= + +.include diff --git a/commands/ibm/atnormalize.c b/commands/atnormalize/atnormalize.c similarity index 100% rename from commands/ibm/atnormalize.c rename to commands/atnormalize/atnormalize.c diff --git a/commands/autil/Makefile b/commands/autil/Makefile index f1a6450b5..d6bff2f34 100644 --- a/commands/autil/Makefile +++ b/commands/autil/Makefile @@ -1,26 +1,10 @@ # Makefile for commands/autil -CC = exec cc -CFLAGS = -I. -D_MINIX -D_POSIX_SOURCE -wo -CCLD = $(CC) -i $(CFLAGS) +PROGS= anm asize +SRCS.anm= anm.c rd.c rd_arhdr.c rd_bytes.c rd_unsig2.c +SRCS.asize= asize.c +CPPFLAGS+= -I${.CURDIR} -wo +MAN.anm= +MAN.asize= -all: anm asize - -anm: anm.c rd.c rd_arhdr.c rd_bytes.c rd_unsig2.c - $(CCLD) -o $@ $? - install -S 32kw $@ - -asize: asize.c - $(CCLD) -o $@ $? - install -S 4kw $@ - -install: /usr/bin/anm /usr/bin/asize - -/usr/bin/anm: anm - install -cs -o bin $? $@ - -/usr/bin/asize: asize - install -cs -o bin $? $@ - -clean: - rm -f anm asize core +.include diff --git a/commands/autil/build b/commands/autil/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/autil/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/autopart/Makefile b/commands/autopart/Makefile new file mode 100644 index 000000000..eb89058eb --- /dev/null +++ b/commands/autopart/Makefile @@ -0,0 +1,4 @@ +PROG= autopart +MAN= + +.include diff --git a/commands/ibm/autopart.c b/commands/autopart/autopart.c similarity index 100% rename from commands/ibm/autopart.c rename to commands/autopart/autopart.c diff --git a/commands/awk/Makefile b/commands/awk/Makefile index 7f8a389e2..e2f3438ab 100644 --- a/commands/awk/Makefile +++ b/commands/awk/Makefile @@ -1,94 +1,7 @@ -# /**************************************************************** -# Copyright (C) Lucent Technologies 1997 -# All Rights Reserved -# -# Permission to use, copy, modify, and distribute this software and -# its documentation for any purpose and without fee is hereby -# granted, provided that the above copyright notice appear in all -# copies and that both that the copyright notice and this -# permission notice and warranty disclaimer appear in supporting -# documentation, and that the name Lucent Technologies or any of -# its entities not be used in advertising or publicity pertaining -# to distribution of the software without specific, written prior -# permission. -# -# LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -# IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -# SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -# THIS SOFTWARE. -# ****************************************************************/ +.include -CFLAGS = -g -CFLAGS = -O2 -CFLAGS = +PROG= awk +SRCS= awkgram.y b.c lex.c lib.c main.c parse.c proctab.c run.c tran.c +YHEADER= yes -CC = gcc -Wall -g -Wwrite-strings -CC = gcc -fprofile-arcs -ftest-coverage # then gcov f1.c; cat f1.c.gcov -CC = gcc -Wall -g -CC = cc -CC = gcc -O4 -CC = cc -O - - -YACC = bison -y -YACC = yacc -YFLAGS = -d - -OFILES = b.o main.o parse.o proctab.o tran.o lib.o run.o lex.o - -SOURCE = awk.h ytab.c ytab.h proto.h awkgram.y lex.c b.c main.c \ - maketab.c parse.c lib.c run.c tran.c proctab.c missing95.c - -LISTING = awk.h proto.h awkgram.y lex.c b.c main.c maketab.c parse.c \ - lib.c run.c tran.c missing95.c - -SHIP = README FIXES $(SOURCE) ytab[ch].bak makefile makefile.win \ - vcvars32.bat buildwin.bat awk.1 - -all: awk - -install: awk awk.1 - install -m 755 -o bin -g operator awk /usr/bin/awk - install -m 644 -o bin -g operator awk.1 /usr/man/man1 - -awk: ytab.o $(OFILES) - $(CC) $(CFLAGS) ytab.o $(OFILES) $(ALLOC) -lm -o $@ - -$(OFILES): awk.h ytab.h proto.h - -ytab.o ytab.c ytab.h: awk.h proto.h awkgram.y - $(YACC) $(YFLAGS) awkgram.y 2>/dev/null - mv y.tab.c ytab.c - mv y.tab.h ytab.h - $(CC) $(CFLAGS) -c ytab.c - -proctab.c: maketab - ./maketab >proctab.c - -maketab: ytab.h maketab.c - $(CC) $(CFLAGS) maketab.c -o maketab - -bundle: - @cp ytab.h ytabh.bak - @cp ytab.c ytabc.bak - @bundle $(SHIP) - -tar: - @cp ytab.h ytabh.bak - @cp ytab.c ytabc.bak - @bundle $(SHIP) >awk.shar - @tar cf awk.tar $(SHIP) - gzip awk.tar - ls -l awk.tar.gz - @zip awk.zip $(SHIP) - ls -l awk.zip - -names: - @echo $(LISTING) - -clean: - rm -f awk *.o *.obj maketab maketab.exe *.bb *.bbg *.da *.gcov *.gcno *.gcda # proctab.c +.include diff --git a/commands/awk/Makefile.orig b/commands/awk/Makefile.orig new file mode 100644 index 000000000..7f8a389e2 --- /dev/null +++ b/commands/awk/Makefile.orig @@ -0,0 +1,94 @@ +# /**************************************************************** +# Copyright (C) Lucent Technologies 1997 +# All Rights Reserved +# +# Permission to use, copy, modify, and distribute this software and +# its documentation for any purpose and without fee is hereby +# granted, provided that the above copyright notice appear in all +# copies and that both that the copyright notice and this +# permission notice and warranty disclaimer appear in supporting +# documentation, and that the name Lucent Technologies or any of +# its entities not be used in advertising or publicity pertaining +# to distribution of the software without specific, written prior +# permission. +# +# LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. +# IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY +# SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER +# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +# THIS SOFTWARE. +# ****************************************************************/ + +CFLAGS = -g +CFLAGS = -O2 +CFLAGS = + +CC = gcc -Wall -g -Wwrite-strings +CC = gcc -fprofile-arcs -ftest-coverage # then gcov f1.c; cat f1.c.gcov +CC = gcc -Wall -g +CC = cc +CC = gcc -O4 +CC = cc -O + + +YACC = bison -y +YACC = yacc +YFLAGS = -d + +OFILES = b.o main.o parse.o proctab.o tran.o lib.o run.o lex.o + +SOURCE = awk.h ytab.c ytab.h proto.h awkgram.y lex.c b.c main.c \ + maketab.c parse.c lib.c run.c tran.c proctab.c missing95.c + +LISTING = awk.h proto.h awkgram.y lex.c b.c main.c maketab.c parse.c \ + lib.c run.c tran.c missing95.c + +SHIP = README FIXES $(SOURCE) ytab[ch].bak makefile makefile.win \ + vcvars32.bat buildwin.bat awk.1 + +all: awk + +install: awk awk.1 + install -m 755 -o bin -g operator awk /usr/bin/awk + install -m 644 -o bin -g operator awk.1 /usr/man/man1 + +awk: ytab.o $(OFILES) + $(CC) $(CFLAGS) ytab.o $(OFILES) $(ALLOC) -lm -o $@ + +$(OFILES): awk.h ytab.h proto.h + +ytab.o ytab.c ytab.h: awk.h proto.h awkgram.y + $(YACC) $(YFLAGS) awkgram.y 2>/dev/null + mv y.tab.c ytab.c + mv y.tab.h ytab.h + $(CC) $(CFLAGS) -c ytab.c + +proctab.c: maketab + ./maketab >proctab.c + +maketab: ytab.h maketab.c + $(CC) $(CFLAGS) maketab.c -o maketab + +bundle: + @cp ytab.h ytabh.bak + @cp ytab.c ytabc.bak + @bundle $(SHIP) + +tar: + @cp ytab.h ytabh.bak + @cp ytab.c ytabc.bak + @bundle $(SHIP) >awk.shar + @tar cf awk.tar $(SHIP) + gzip awk.tar + ls -l awk.tar.gz + @zip awk.zip $(SHIP) + ls -l awk.zip + +names: + @echo $(LISTING) + +clean: + rm -f awk *.o *.obj maketab maketab.exe *.bb *.bbg *.da *.gcov *.gcno *.gcda # proctab.c diff --git a/commands/awk/b.c b/commands/awk/b.c index 75c6992be..0fbfab1fb 100644 --- a/commands/awk/b.c +++ b/commands/awk/b.c @@ -31,7 +31,7 @@ THIS SOFTWARE. #include #include #include "awk.h" -#include "ytab.h" +#include "awkgram.h" #define HAT (NCHARS+2) /* matches ^ in regular expr */ /* NCHARS is 2**n */ diff --git a/commands/awk/buildwin.bat b/commands/awk/buildwin.bat deleted file mode 100644 index 77513429e..000000000 --- a/commands/awk/buildwin.bat +++ /dev/null @@ -1,12 +0,0 @@ -@echo off -rem buildwin.bat - build AWK under Windows NT using Visual C++. -rem 22 Jan 1999 - Created by Dan Allen. -rem -rem If you delete the call to setlocal it will probably work under Win95/Win98 as well. - -setlocal -set cl=-w -Ox -QIfdiv- -nologo -link -nologo setargv.obj - -cl maketab.c -o maketab.exe -maketab.exe > proctab.c -cl -o awk.exe b.c main.c parse.c proctab.c tran.c lib.c run.c lex.c ytab.c missing95.c diff --git a/commands/awk/lex.c b/commands/awk/lex.c index a7e225d77..8c59c4a0b 100644 --- a/commands/awk/lex.c +++ b/commands/awk/lex.c @@ -27,7 +27,7 @@ THIS SOFTWARE. #include #include #include "awk.h" -#include "ytab.h" +#include "awkgram.h" extern YYSTYPE yylval; extern int infunc; diff --git a/commands/awk/lib.c b/commands/awk/lib.c index 017b37670..8ba14e6df 100644 --- a/commands/awk/lib.c +++ b/commands/awk/lib.c @@ -30,7 +30,7 @@ THIS SOFTWARE. #include #include #include "awk.h" -#include "ytab.h" +#include "awkgram.h" FILE *infile = NULL; char *file = ""; diff --git a/commands/awk/main.c b/commands/awk/main.c index 3bc91b54e..704599ce4 100644 --- a/commands/awk/main.c +++ b/commands/awk/main.c @@ -32,7 +32,7 @@ const char *version = "version 20100208"; #include #include #include "awk.h" -#include "ytab.h" +#include "awkgram.h" extern char **environ; extern int nfields; diff --git a/commands/awk/makefile.win b/commands/awk/makefile.win deleted file mode 100644 index 209c7f18c..000000000 --- a/commands/awk/makefile.win +++ /dev/null @@ -1,9 +0,0 @@ -# vestigial makefile for microsoft c compiler on WinXX -# run with nmake -f makefile.win -# based on buildwin.bat - -awk95.exe: - set cl=-w -Ox -QIfdiv- -nologo -link -nologo setargv.obj - cl maketab.c -o maketab.exe - .\maketab.exe > proctab.c - cl -o awk95.exe b.c main.c parse.c proctab.c tran.c lib.c run.c lex.c ytab.c missing95.c diff --git a/commands/awk/maketab.c b/commands/awk/maketab.c index 31acd7522..739c36683 100644 --- a/commands/awk/maketab.c +++ b/commands/awk/maketab.c @@ -32,7 +32,7 @@ THIS SOFTWARE. #include #include #include "awk.h" -#include "ytab.h" +#include "awkgram.h" struct xx { int token; diff --git a/commands/awk/missing95.c b/commands/awk/missing95.c deleted file mode 100644 index 00c3f3a5e..000000000 --- a/commands/awk/missing95.c +++ /dev/null @@ -1,12 +0,0 @@ -/* popen and pclose are not part of win 95 and nt, - but it appears that _popen and _pclose "work". - if this won't load, use the return NULL statements. */ - -#include -FILE *popen(char *s, char *m) { - return _popen(s, m); /* return NULL; */ -} - -int pclose(FILE *f) { - return _pclose(f); /* return NULL; */ -} diff --git a/commands/awk/parse.c b/commands/awk/parse.c index 8304ded83..05b4d1a8d 100644 --- a/commands/awk/parse.c +++ b/commands/awk/parse.c @@ -27,7 +27,7 @@ THIS SOFTWARE. #include #include #include "awk.h" -#include "ytab.h" +#include "awkgram.h" Node *nodealloc(int n) { diff --git a/commands/awk/proctab.c b/commands/awk/proctab.c new file mode 100644 index 000000000..f2c735807 --- /dev/null +++ b/commands/awk/proctab.c @@ -0,0 +1,207 @@ +#include +#include "awk.h" +#include "awkgram.h" + +static char *printname[93] = { + (char *) "FIRSTTOKEN", /* 258 */ + (char *) "PROGRAM", /* 259 */ + (char *) "PASTAT", /* 260 */ + (char *) "PASTAT2", /* 261 */ + (char *) "XBEGIN", /* 262 */ + (char *) "XEND", /* 263 */ + (char *) "NL", /* 264 */ + (char *) "ARRAY", /* 265 */ + (char *) "MATCH", /* 266 */ + (char *) "NOTMATCH", /* 267 */ + (char *) "MATCHOP", /* 268 */ + (char *) "FINAL", /* 269 */ + (char *) "DOT", /* 270 */ + (char *) "ALL", /* 271 */ + (char *) "CCL", /* 272 */ + (char *) "NCCL", /* 273 */ + (char *) "CHAR", /* 274 */ + (char *) "OR", /* 275 */ + (char *) "STAR", /* 276 */ + (char *) "QUEST", /* 277 */ + (char *) "PLUS", /* 278 */ + (char *) "EMPTYRE", /* 279 */ + (char *) "AND", /* 280 */ + (char *) "BOR", /* 281 */ + (char *) "APPEND", /* 282 */ + (char *) "EQ", /* 283 */ + (char *) "GE", /* 284 */ + (char *) "GT", /* 285 */ + (char *) "LE", /* 286 */ + (char *) "LT", /* 287 */ + (char *) "NE", /* 288 */ + (char *) "IN", /* 289 */ + (char *) "ARG", /* 290 */ + (char *) "BLTIN", /* 291 */ + (char *) "BREAK", /* 292 */ + (char *) "CLOSE", /* 293 */ + (char *) "CONTINUE", /* 294 */ + (char *) "DELETE", /* 295 */ + (char *) "DO", /* 296 */ + (char *) "EXIT", /* 297 */ + (char *) "FOR", /* 298 */ + (char *) "FUNC", /* 299 */ + (char *) "SUB", /* 300 */ + (char *) "GSUB", /* 301 */ + (char *) "IF", /* 302 */ + (char *) "INDEX", /* 303 */ + (char *) "LSUBSTR", /* 304 */ + (char *) "MATCHFCN", /* 305 */ + (char *) "NEXT", /* 306 */ + (char *) "NEXTFILE", /* 307 */ + (char *) "ADD", /* 308 */ + (char *) "MINUS", /* 309 */ + (char *) "MULT", /* 310 */ + (char *) "DIVIDE", /* 311 */ + (char *) "MOD", /* 312 */ + (char *) "ASSIGN", /* 313 */ + (char *) "ASGNOP", /* 314 */ + (char *) "ADDEQ", /* 315 */ + (char *) "SUBEQ", /* 316 */ + (char *) "MULTEQ", /* 317 */ + (char *) "DIVEQ", /* 318 */ + (char *) "MODEQ", /* 319 */ + (char *) "POWEQ", /* 320 */ + (char *) "PRINT", /* 321 */ + (char *) "PRINTF", /* 322 */ + (char *) "SPRINTF", /* 323 */ + (char *) "ELSE", /* 324 */ + (char *) "INTEST", /* 325 */ + (char *) "CONDEXPR", /* 326 */ + (char *) "POSTINCR", /* 327 */ + (char *) "PREINCR", /* 328 */ + (char *) "POSTDECR", /* 329 */ + (char *) "PREDECR", /* 330 */ + (char *) "VAR", /* 331 */ + (char *) "IVAR", /* 332 */ + (char *) "VARNF", /* 333 */ + (char *) "CALL", /* 334 */ + (char *) "NUMBER", /* 335 */ + (char *) "STRING", /* 336 */ + (char *) "REGEXPR", /* 337 */ + (char *) "GETLINE", /* 338 */ + (char *) "SUBSTR", /* 339 */ + (char *) "SPLIT", /* 340 */ + (char *) "RETURN", /* 341 */ + (char *) "WHILE", /* 342 */ + (char *) "CAT", /* 343 */ + (char *) "UMINUS", /* 344 */ + (char *) "NOT", /* 345 */ + (char *) "POWER", /* 346 */ + (char *) "INCR", /* 347 */ + (char *) "DECR", /* 348 */ + (char *) "INDIRECT", /* 349 */ + (char *) "LASTTOKEN", /* 350 */ +}; + + +Cell *(*proctab[93])(Node **, int) = { + nullproc, /* FIRSTTOKEN */ + program, /* PROGRAM */ + pastat, /* PASTAT */ + dopa2, /* PASTAT2 */ + nullproc, /* XBEGIN */ + nullproc, /* XEND */ + nullproc, /* NL */ + array, /* ARRAY */ + matchop, /* MATCH */ + matchop, /* NOTMATCH */ + nullproc, /* MATCHOP */ + nullproc, /* FINAL */ + nullproc, /* DOT */ + nullproc, /* ALL */ + nullproc, /* CCL */ + nullproc, /* NCCL */ + nullproc, /* CHAR */ + nullproc, /* OR */ + nullproc, /* STAR */ + nullproc, /* QUEST */ + nullproc, /* PLUS */ + nullproc, /* EMPTYRE */ + boolop, /* AND */ + boolop, /* BOR */ + nullproc, /* APPEND */ + relop, /* EQ */ + relop, /* GE */ + relop, /* GT */ + relop, /* LE */ + relop, /* LT */ + relop, /* NE */ + instat, /* IN */ + arg, /* ARG */ + bltin, /* BLTIN */ + jump, /* BREAK */ + closefile, /* CLOSE */ + jump, /* CONTINUE */ + awkdelete, /* DELETE */ + dostat, /* DO */ + jump, /* EXIT */ + forstat, /* FOR */ + nullproc, /* FUNC */ + sub, /* SUB */ + gsub, /* GSUB */ + ifstat, /* IF */ + sindex, /* INDEX */ + nullproc, /* LSUBSTR */ + matchop, /* MATCHFCN */ + jump, /* NEXT */ + jump, /* NEXTFILE */ + arith, /* ADD */ + arith, /* MINUS */ + arith, /* MULT */ + arith, /* DIVIDE */ + arith, /* MOD */ + assign, /* ASSIGN */ + nullproc, /* ASGNOP */ + assign, /* ADDEQ */ + assign, /* SUBEQ */ + assign, /* MULTEQ */ + assign, /* DIVEQ */ + assign, /* MODEQ */ + assign, /* POWEQ */ + printstat, /* PRINT */ + awkprintf, /* PRINTF */ + awksprintf, /* SPRINTF */ + nullproc, /* ELSE */ + intest, /* INTEST */ + condexpr, /* CONDEXPR */ + incrdecr, /* POSTINCR */ + incrdecr, /* PREINCR */ + incrdecr, /* POSTDECR */ + incrdecr, /* PREDECR */ + nullproc, /* VAR */ + nullproc, /* IVAR */ + getnf, /* VARNF */ + call, /* CALL */ + nullproc, /* NUMBER */ + nullproc, /* STRING */ + nullproc, /* REGEXPR */ + awkgetline, /* GETLINE */ + substr, /* SUBSTR */ + split, /* SPLIT */ + jump, /* RETURN */ + whilestat, /* WHILE */ + cat, /* CAT */ + arith, /* UMINUS */ + boolop, /* NOT */ + arith, /* POWER */ + nullproc, /* INCR */ + nullproc, /* DECR */ + indirect, /* INDIRECT */ + nullproc, /* LASTTOKEN */ +}; + +char *tokname(int n) +{ + static char buf[100]; + + if (n < FIRSTTOKEN || n > LASTTOKEN) { + sprintf(buf, "token %d", n); + return buf; + } + return printname[n-FIRSTTOKEN]; +} diff --git a/commands/awk/run.c b/commands/awk/run.c index 72fc4d0f4..128761042 100644 --- a/commands/awk/run.c +++ b/commands/awk/run.c @@ -32,7 +32,7 @@ THIS SOFTWARE. #include #include #include "awk.h" -#include "ytab.h" +#include "awkgram.h" #define tempfree(x) if (istemp(x)) tfree(x); else diff --git a/commands/awk/tran.c b/commands/awk/tran.c index 57dd281b3..24affc104 100644 --- a/commands/awk/tran.c +++ b/commands/awk/tran.c @@ -29,7 +29,7 @@ THIS SOFTWARE. #include #include #include "awk.h" -#include "ytab.h" +#include "awkgram.h" #define FULLTAB 2 /* rehash when table gets this x full */ #define GROWTAB 4 /* grow table by this factor */ diff --git a/commands/awk/vcvars32.bat b/commands/awk/vcvars32.bat deleted file mode 100644 index c3be8ed99..000000000 --- a/commands/awk/vcvars32.bat +++ /dev/null @@ -1,33 +0,0 @@ -@echo off -rem -rem Root of Visual Developer Studio Common files. -set VSCommonDir=C:\PROGRA~1\MICROS~3\Common - -rem -rem Root of Visual Developer Studio installed files. -rem -set MSDevDir=C:\PROGRA~1\MICROS~3\Common\msdev98 - -rem -rem Root of Visual C++ installed files. -rem -set MSVCDir=C:\PROGRA~1\MICROS~3\VC98 - -rem -rem VcOsDir is used to help create either a Windows 95 or Windows NT specific path. -rem -set VcOsDir=WIN95 -if "%OS%" == "Windows_NT" set VcOsDir=WINNT - -rem -echo Setting environment for using Microsoft Visual C++ tools. -rem - -if "%OS%" == "Windows_NT" set PATH=%MSDevDir%\BIN;%MSVCDir%\BIN;%VSCommonDir%\TOOLS\%VcOsDir%;%VSCommonDir%\TOOLS;%PATH% -if "%OS%" == "" set PATH="%MSDevDir%\BIN";"%MSVCDir%\BIN";"%VSCommonDir%\TOOLS\%VcOsDir%";"%VSCommonDir%\TOOLS";"%windir%\SYSTEM";"%PATH%" -set INCLUDE=%MSVCDir%\ATL\INCLUDE;%MSVCDir%\INCLUDE;%MSVCDir%\MFC\INCLUDE;%INCLUDE% -set LIB=%MSVCDir%\LIB;%MSVCDir%\MFC\LIB;%LIB% - -set VcOsDir= -set VSCommonDir= - diff --git a/commands/awk/ytabc.bak b/commands/awk/ytabc.bak deleted file mode 100644 index cc8e84879..000000000 --- a/commands/awk/ytabc.bak +++ /dev/null @@ -1,3707 +0,0 @@ -/* A Bison parser, made by GNU Bison 2.3. */ - -/* Skeleton implementation for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -/* C LALR(1) parser skeleton written by Richard Stallman, by - simplifying the original so-called "semantic" parser. */ - -/* All symbols defined below should begin with yy or YY, to avoid - infringing on user name space. This should be done even for local - variables, as they might otherwise be expanded by user macros. - There are some unavoidable exceptions within include files to - define necessary library symbols; they are noted "INFRINGES ON - USER NAME SPACE" below. */ - -/* Identify Bison output. */ -#define YYBISON 1 - -/* Bison version. */ -#define YYBISON_VERSION "2.3" - -/* Skeleton name. */ -#define YYSKELETON_NAME "yacc.c" - -/* Pure parsers. */ -#define YYPURE 0 - -/* Using locations. */ -#define YYLSP_NEEDED 0 - - - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - FIRSTTOKEN = 258, - PROGRAM = 259, - PASTAT = 260, - PASTAT2 = 261, - XBEGIN = 262, - XEND = 263, - NL = 264, - ARRAY = 265, - MATCH = 266, - NOTMATCH = 267, - MATCHOP = 268, - FINAL = 269, - DOT = 270, - ALL = 271, - CCL = 272, - NCCL = 273, - CHAR = 274, - OR = 275, - STAR = 276, - QUEST = 277, - PLUS = 278, - EMPTYRE = 279, - AND = 280, - BOR = 281, - APPEND = 282, - EQ = 283, - GE = 284, - GT = 285, - LE = 286, - LT = 287, - NE = 288, - IN = 289, - ARG = 290, - BLTIN = 291, - BREAK = 292, - CLOSE = 293, - CONTINUE = 294, - DELETE = 295, - DO = 296, - EXIT = 297, - FOR = 298, - FUNC = 299, - SUB = 300, - GSUB = 301, - IF = 302, - INDEX = 303, - LSUBSTR = 304, - MATCHFCN = 305, - NEXT = 306, - NEXTFILE = 307, - ADD = 308, - MINUS = 309, - MULT = 310, - DIVIDE = 311, - MOD = 312, - ASSIGN = 313, - ASGNOP = 314, - ADDEQ = 315, - SUBEQ = 316, - MULTEQ = 317, - DIVEQ = 318, - MODEQ = 319, - POWEQ = 320, - PRINT = 321, - PRINTF = 322, - SPRINTF = 323, - ELSE = 324, - INTEST = 325, - CONDEXPR = 326, - POSTINCR = 327, - PREINCR = 328, - POSTDECR = 329, - PREDECR = 330, - VAR = 331, - IVAR = 332, - VARNF = 333, - CALL = 334, - NUMBER = 335, - STRING = 336, - REGEXPR = 337, - GETLINE = 338, - SUBSTR = 339, - SPLIT = 340, - RETURN = 341, - WHILE = 342, - CAT = 343, - UMINUS = 344, - NOT = 345, - POWER = 346, - INCR = 347, - DECR = 348, - INDIRECT = 349, - LASTTOKEN = 350 - }; -#endif -/* Tokens. */ -#define FIRSTTOKEN 258 -#define PROGRAM 259 -#define PASTAT 260 -#define PASTAT2 261 -#define XBEGIN 262 -#define XEND 263 -#define NL 264 -#define ARRAY 265 -#define MATCH 266 -#define NOTMATCH 267 -#define MATCHOP 268 -#define FINAL 269 -#define DOT 270 -#define ALL 271 -#define CCL 272 -#define NCCL 273 -#define CHAR 274 -#define OR 275 -#define STAR 276 -#define QUEST 277 -#define PLUS 278 -#define EMPTYRE 279 -#define AND 280 -#define BOR 281 -#define APPEND 282 -#define EQ 283 -#define GE 284 -#define GT 285 -#define LE 286 -#define LT 287 -#define NE 288 -#define IN 289 -#define ARG 290 -#define BLTIN 291 -#define BREAK 292 -#define CLOSE 293 -#define CONTINUE 294 -#define DELETE 295 -#define DO 296 -#define EXIT 297 -#define FOR 298 -#define FUNC 299 -#define SUB 300 -#define GSUB 301 -#define IF 302 -#define INDEX 303 -#define LSUBSTR 304 -#define MATCHFCN 305 -#define NEXT 306 -#define NEXTFILE 307 -#define ADD 308 -#define MINUS 309 -#define MULT 310 -#define DIVIDE 311 -#define MOD 312 -#define ASSIGN 313 -#define ASGNOP 314 -#define ADDEQ 315 -#define SUBEQ 316 -#define MULTEQ 317 -#define DIVEQ 318 -#define MODEQ 319 -#define POWEQ 320 -#define PRINT 321 -#define PRINTF 322 -#define SPRINTF 323 -#define ELSE 324 -#define INTEST 325 -#define CONDEXPR 326 -#define POSTINCR 327 -#define PREINCR 328 -#define POSTDECR 329 -#define PREDECR 330 -#define VAR 331 -#define IVAR 332 -#define VARNF 333 -#define CALL 334 -#define NUMBER 335 -#define STRING 336 -#define REGEXPR 337 -#define GETLINE 338 -#define SUBSTR 339 -#define SPLIT 340 -#define RETURN 341 -#define WHILE 342 -#define CAT 343 -#define UMINUS 344 -#define NOT 345 -#define POWER 346 -#define INCR 347 -#define DECR 348 -#define INDIRECT 349 -#define LASTTOKEN 350 - - - - -/* Copy the first part of user declarations. */ -#line 25 "awkgram.y" - -#include -#include -#include "awk.h" - -void checkdup(Node *list, Cell *item); -int yywrap(void) { return(1); } - -Node *beginloc = 0; -Node *endloc = 0; -int infunc = 0; /* = 1 if in arglist or body of func */ -int inloop = 0; /* = 1 if in while, for, do */ -char *curfname = 0; /* current function name */ -Node *arglist = 0; /* list of args for current function */ - - -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif - -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 0 -#endif - -/* Enabling the token table. */ -#ifndef YYTOKEN_TABLE -# define YYTOKEN_TABLE 0 -#endif - -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE -#line 41 "awkgram.y" -{ - Node *p; - Cell *cp; - int i; - char *s; -} -/* Line 193 of yacc.c. */ -#line 309 "y.tab.c" - YYSTYPE; -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 -#endif - - - -/* Copy the second part of user declarations. */ - - -/* Line 216 of yacc.c. */ -#line 322 "y.tab.c" - -#ifdef short -# undef short -#endif - -#ifdef YYTYPE_UINT8 -typedef YYTYPE_UINT8 yytype_uint8; -#else -typedef unsigned char yytype_uint8; -#endif - -#ifdef YYTYPE_INT8 -typedef YYTYPE_INT8 yytype_int8; -#elif (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -typedef signed char yytype_int8; -#else -typedef short int yytype_int8; -#endif - -#ifdef YYTYPE_UINT16 -typedef YYTYPE_UINT16 yytype_uint16; -#else -typedef unsigned short int yytype_uint16; -#endif - -#ifdef YYTYPE_INT16 -typedef YYTYPE_INT16 yytype_int16; -#else -typedef short int yytype_int16; -#endif - -#ifndef YYSIZE_T -# ifdef __SIZE_TYPE__ -# define YYSIZE_T __SIZE_TYPE__ -# elif defined size_t -# define YYSIZE_T size_t -# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# else -# define YYSIZE_T unsigned int -# endif -#endif - -#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) - -#ifndef YY_ -# if defined YYENABLE_NLS && YYENABLE_NLS -# if ENABLE_NLS -# include /* INFRINGES ON USER NAME SPACE */ -# define YY_(msgid) dgettext ("bison-runtime", msgid) -# endif -# endif -# ifndef YY_ -# define YY_(msgid) msgid -# endif -#endif - -/* Suppress unused-variable warnings by "using" E. */ -#if ! defined lint || defined __GNUC__ -# define YYUSE(e) ((void) (e)) -#else -# define YYUSE(e) /* empty */ -#endif - -/* Identity function, used to suppress warnings about constant conditions. */ -#ifndef lint -# define YYID(n) (n) -#else -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static int -YYID (int i) -#else -static int -YYID (i) - int i; -#endif -{ - return i; -} -#endif - -#if ! defined yyoverflow || YYERROR_VERBOSE - -/* The parser invokes alloca or malloc; define the necessary symbols. */ - -# ifdef YYSTACK_USE_ALLOCA -# if YYSTACK_USE_ALLOCA -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# elif defined __BUILTIN_VA_ARG_INCR -# include /* INFRINGES ON USER NAME SPACE */ -# elif defined _AIX -# define YYSTACK_ALLOC __alloca -# elif defined _MSC_VER -# include /* INFRINGES ON USER NAME SPACE */ -# define alloca _alloca -# else -# define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -# include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 -# endif -# endif -# endif -# endif -# endif - -# ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) -# ifndef YYSTACK_ALLOC_MAXIMUM - /* The OS might guarantee only one guard page at the bottom of the stack, - and a page size can be as small as 4096 bytes. So we cannot safely - invoke alloca (N) if N exceeds 4096. Use a slightly smaller number - to allow for a few compiler-allocated temporary stack slots. */ -# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ -# endif -# else -# define YYSTACK_ALLOC YYMALLOC -# define YYSTACK_FREE YYFREE -# ifndef YYSTACK_ALLOC_MAXIMUM -# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM -# endif -# if (defined __cplusplus && ! defined _STDLIB_H \ - && ! ((defined YYMALLOC || defined malloc) \ - && (defined YYFREE || defined free))) -# include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 -# endif -# endif -# ifndef YYMALLOC -# define YYMALLOC malloc -# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# ifndef YYFREE -# define YYFREE free -# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -void free (void *); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# endif -#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ - - -#if (! defined yyoverflow \ - && (! defined __cplusplus \ - || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) - -/* A type that is properly aligned for any stack member. */ -union yyalloc -{ - yytype_int16 yyss; - YYSTYPE yyvs; - }; - -/* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) - -/* The size of an array large to enough to hold all stacks, each with - N elements. */ -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ - + YYSTACK_GAP_MAXIMUM) - -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if defined __GNUC__ && 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (YYID (0)) -# endif -# endif - -/* Relocate STACK from its old location to the new one. The - local variables YYSIZE and YYSTACKSIZE give the old and new number of - elements in the stack, and YYPTR gives the new location of the - stack. Advance YYPTR to a properly aligned location for the next - stack. */ -# define YYSTACK_RELOCATE(Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (YYID (0)) - -#endif - -/* YYFINAL -- State number of the termination state. */ -#define YYFINAL 8 -/* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 4600 - -/* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 112 -/* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 49 -/* YYNRULES -- Number of rules. */ -#define YYNRULES 185 -/* YYNRULES -- Number of states. */ -#define YYNSTATES 367 - -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ -#define YYUNDEFTOK 2 -#define YYMAXUTOK 350 - -#define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) - -/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ -static const yytype_uint8 yytranslate[] = -{ - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 104, 2, 2, - 12, 16, 103, 101, 9, 102, 2, 15, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 94, 14, - 2, 2, 2, 93, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 18, 2, 19, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 11, 13, 17, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, - 5, 6, 7, 8, 10, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, - 85, 86, 87, 88, 89, 90, 91, 92, 95, 96, - 97, 98, 99, 100, 105, 106, 107, 108, 109, 110, - 111 -}; - -#if YYDEBUG -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ -static const yytype_uint16 yyprhs[] = -{ - 0, 0, 3, 5, 7, 9, 12, 14, 17, 19, - 22, 24, 27, 29, 32, 33, 46, 47, 58, 59, - 68, 70, 72, 77, 79, 82, 84, 87, 88, 90, - 91, 93, 94, 96, 98, 102, 104, 106, 111, 115, - 122, 126, 131, 136, 137, 147, 149, 153, 155, 159, - 163, 169, 173, 177, 181, 185, 189, 195, 198, 200, - 202, 206, 212, 216, 220, 224, 228, 232, 236, 240, - 244, 248, 252, 256, 262, 267, 271, 274, 276, 278, - 282, 286, 288, 292, 293, 295, 299, 301, 303, 305, - 307, 310, 313, 315, 318, 320, 323, 324, 329, 331, - 334, 339, 344, 349, 352, 358, 361, 363, 365, 367, - 370, 373, 376, 377, 378, 388, 392, 395, 397, 402, - 405, 409, 412, 415, 419, 422, 425, 426, 430, 433, - 435, 438, 440, 442, 447, 451, 455, 459, 463, 467, - 471, 474, 477, 480, 484, 489, 491, 495, 500, 503, - 506, 509, 512, 515, 520, 524, 527, 529, 536, 543, - 547, 554, 561, 563, 572, 581, 588, 593, 595, 602, - 609, 618, 627, 636, 643, 645, 647, 652, 654, 657, - 658, 660, 664, 666, 668, 670 -}; - -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const yytype_int16 yyrhs[] = -{ - 113, 0, -1, 130, -1, 1, -1, 35, -1, 114, - 10, -1, 36, -1, 115, 10, -1, 9, -1, 116, - 10, -1, 51, -1, 117, 10, -1, 79, -1, 118, - 10, -1, -1, 53, 12, 129, 14, 127, 137, 14, - 127, 129, 147, 120, 150, -1, -1, 53, 12, 129, - 14, 14, 127, 129, 147, 121, 150, -1, -1, 53, - 12, 159, 44, 159, 147, 122, 150, -1, 86, -1, - 89, -1, 57, 12, 137, 147, -1, 11, -1, 125, - 10, -1, 10, -1, 126, 10, -1, -1, 126, -1, - -1, 142, -1, -1, 148, -1, 128, -1, 128, 134, - 128, -1, 137, -1, 131, -1, 131, 125, 154, 17, - -1, 131, 9, 131, -1, 131, 9, 131, 125, 154, - 17, -1, 125, 154, 17, -1, 7, 125, 154, 17, - -1, 8, 125, 154, 17, -1, -1, 54, 123, 12, - 158, 147, 133, 125, 154, 17, -1, 132, -1, 134, - 128, 132, -1, 137, -1, 135, 116, 137, -1, 157, - 69, 136, -1, 136, 93, 136, 94, 136, -1, 136, - 115, 136, -1, 136, 114, 136, -1, 136, 23, 145, - -1, 136, 23, 136, -1, 136, 44, 159, -1, 12, - 138, 16, 44, 159, -1, 136, 156, -1, 144, -1, - 156, -1, 157, 69, 137, -1, 137, 93, 137, 94, - 137, -1, 137, 115, 137, -1, 137, 114, 137, -1, - 137, 38, 137, -1, 137, 39, 137, -1, 137, 40, - 137, -1, 137, 41, 137, -1, 137, 42, 137, -1, - 137, 43, 137, -1, 137, 23, 145, -1, 137, 23, - 137, -1, 137, 44, 159, -1, 12, 138, 16, 44, - 159, -1, 137, 13, 95, 157, -1, 137, 13, 95, - -1, 137, 156, -1, 144, -1, 156, -1, 137, 116, - 137, -1, 138, 116, 137, -1, 136, -1, 139, 116, - 136, -1, -1, 139, -1, 12, 138, 16, -1, 76, - -1, 77, -1, 10, -1, 14, -1, 142, 10, -1, - 142, 14, -1, 17, -1, 143, 10, -1, 145, -1, - 106, 144, -1, -1, 15, 146, 92, 15, -1, 16, - -1, 147, 10, -1, 141, 140, 13, 156, -1, 141, - 140, 37, 156, -1, 141, 140, 40, 156, -1, 141, - 140, -1, 50, 159, 18, 135, 19, -1, 50, 159, - -1, 137, -1, 1, -1, 126, -1, 14, 127, -1, - 47, 149, -1, 49, 149, -1, -1, -1, 117, 151, - 150, 152, 99, 12, 137, 16, 149, -1, 52, 137, - 149, -1, 52, 149, -1, 119, -1, 124, 150, 118, - 150, -1, 124, 150, -1, 125, 154, 143, -1, 61, - 149, -1, 62, 149, -1, 98, 137, 149, -1, 98, - 149, -1, 148, 149, -1, -1, 160, 153, 150, -1, - 14, 127, -1, 150, -1, 154, 150, -1, 55, -1, - 56, -1, 156, 15, 69, 156, -1, 156, 101, 156, - -1, 156, 102, 156, -1, 156, 103, 156, -1, 156, - 15, 156, -1, 156, 104, 156, -1, 156, 107, 156, - -1, 102, 156, -1, 101, 156, -1, 106, 156, -1, - 46, 12, 16, -1, 46, 12, 135, 16, -1, 46, - -1, 89, 12, 16, -1, 89, 12, 135, 16, -1, - 48, 156, -1, 109, 157, -1, 108, 157, -1, 157, - 109, -1, 157, 108, -1, 95, 157, 42, 156, -1, - 95, 42, 156, -1, 95, 157, -1, 95, -1, 58, - 12, 137, 116, 137, 16, -1, 58, 12, 137, 116, - 145, 16, -1, 12, 137, 16, -1, 60, 12, 137, - 116, 145, 16, -1, 60, 12, 137, 116, 137, 16, - -1, 90, -1, 97, 12, 137, 116, 159, 116, 137, - 16, -1, 97, 12, 137, 116, 159, 116, 145, 16, - -1, 97, 12, 137, 116, 159, 16, -1, 78, 12, - 135, 16, -1, 91, -1, 155, 12, 145, 116, 137, - 16, -1, 155, 12, 137, 116, 137, 16, -1, 155, - 12, 145, 116, 137, 116, 157, 16, -1, 155, 12, - 137, 116, 137, 116, 157, 16, -1, 96, 12, 137, - 116, 137, 116, 137, 16, -1, 96, 12, 137, 116, - 137, 16, -1, 157, -1, 159, -1, 159, 18, 135, - 19, -1, 87, -1, 110, 156, -1, -1, 86, -1, - 158, 116, 86, -1, 86, -1, 45, -1, 88, -1, - 99, 12, 137, 147, -1 -}; - -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const yytype_uint16 yyrline[] = -{ - 0, 98, 98, 100, 104, 104, 108, 108, 112, 112, - 116, 116, 120, 120, 124, 124, 126, 126, 128, 128, - 133, 134, 138, 142, 142, 146, 146, 150, 151, 155, - 156, 161, 162, 166, 167, 171, 175, 176, 177, 178, - 179, 180, 182, 184, 184, 189, 190, 194, 195, 199, - 200, 202, 204, 206, 207, 212, 213, 214, 215, 216, - 220, 221, 223, 225, 227, 228, 229, 230, 231, 232, - 233, 234, 239, 240, 241, 244, 247, 248, 249, 253, - 254, 258, 259, 263, 264, 265, 269, 269, 273, 273, - 273, 273, 277, 277, 281, 283, 287, 287, 291, 291, - 295, 298, 301, 304, 305, 306, 307, 308, 312, 313, - 317, 319, 321, 321, 321, 323, 324, 325, 326, 327, - 328, 329, 332, 335, 336, 337, 338, 338, 339, 343, - 344, 348, 348, 352, 353, 354, 355, 356, 357, 358, - 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, - 369, 370, 371, 372, 373, 374, 375, 376, 378, 381, - 382, 384, 389, 390, 392, 394, 396, 397, 398, 400, - 405, 407, 412, 414, 416, 420, 421, 422, 423, 427, - 428, 429, 435, 436, 437, 442 -}; -#endif - -#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE -/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ -static const char *const yytname[] = -{ - "$end", "error", "$undefined", "FIRSTTOKEN", "PROGRAM", "PASTAT", - "PASTAT2", "XBEGIN", "XEND", "','", "NL", "'{'", "'('", "'|'", "';'", - "'/'", "')'", "'}'", "'['", "']'", "ARRAY", "MATCH", "NOTMATCH", - "MATCHOP", "FINAL", "DOT", "ALL", "CCL", "NCCL", "CHAR", "OR", "STAR", - "QUEST", "PLUS", "EMPTYRE", "AND", "BOR", "APPEND", "EQ", "GE", "GT", - "LE", "LT", "NE", "IN", "ARG", "BLTIN", "BREAK", "CLOSE", "CONTINUE", - "DELETE", "DO", "EXIT", "FOR", "FUNC", "SUB", "GSUB", "IF", "INDEX", - "LSUBSTR", "MATCHFCN", "NEXT", "NEXTFILE", "ADD", "MINUS", "MULT", - "DIVIDE", "MOD", "ASSIGN", "ASGNOP", "ADDEQ", "SUBEQ", "MULTEQ", "DIVEQ", - "MODEQ", "POWEQ", "PRINT", "PRINTF", "SPRINTF", "ELSE", "INTEST", - "CONDEXPR", "POSTINCR", "PREINCR", "POSTDECR", "PREDECR", "VAR", "IVAR", - "VARNF", "CALL", "NUMBER", "STRING", "REGEXPR", "'?'", "':'", "GETLINE", - "SUBSTR", "SPLIT", "RETURN", "WHILE", "CAT", "'+'", "'-'", "'*'", "'%'", - "UMINUS", "NOT", "POWER", "INCR", "DECR", "INDIRECT", "LASTTOKEN", - "$accept", "program", "and", "bor", "comma", "do", "else", "for", "@1", - "@2", "@3", "funcname", "if", "lbrace", "nl", "opt_nl", "opt_pst", - "opt_simple_stmt", "pas", "pa_pat", "pa_stat", "@4", "pa_stats", - "patlist", "ppattern", "pattern", "plist", "pplist", "prarg", "print", - "pst", "rbrace", "re", "reg_expr", "@5", "rparen", "simple_stmt", "st", - "stmt", "@6", "@7", "@8", "stmtlist", "subop", "term", "var", "varlist", - "varname", "while", 0 -}; -#endif - -# ifdef YYPRINT -/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to - token YYLEX-NUM. */ -static const yytype_uint16 yytoknum[] = -{ - 0, 256, 257, 258, 259, 260, 261, 262, 263, 44, - 264, 123, 40, 124, 59, 47, 41, 125, 91, 93, - 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, - 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, - 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, - 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, - 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, - 335, 336, 337, 63, 58, 338, 339, 340, 341, 342, - 343, 43, 45, 42, 37, 344, 345, 346, 347, 348, - 349, 350 -}; -# endif - -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint8 yyr1[] = -{ - 0, 112, 113, 113, 114, 114, 115, 115, 116, 116, - 117, 117, 118, 118, 120, 119, 121, 119, 122, 119, - 123, 123, 124, 125, 125, 126, 126, 127, 127, 128, - 128, 129, 129, 130, 130, 131, 132, 132, 132, 132, - 132, 132, 132, 133, 132, 134, 134, 135, 135, 136, - 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, - 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, - 137, 137, 137, 137, 137, 137, 137, 137, 137, 138, - 138, 139, 139, 140, 140, 140, 141, 141, 142, 142, - 142, 142, 143, 143, 144, 144, 146, 145, 147, 147, - 148, 148, 148, 148, 148, 148, 148, 148, 149, 149, - 150, 150, 151, 152, 150, 150, 150, 150, 150, 150, - 150, 150, 150, 150, 150, 150, 153, 150, 150, 154, - 154, 155, 155, 156, 156, 156, 156, 156, 156, 156, - 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, - 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, - 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, - 156, 156, 156, 156, 156, 157, 157, 157, 157, 158, - 158, 158, 159, 159, 159, 160 -}; - -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = -{ - 0, 2, 1, 1, 1, 2, 1, 2, 1, 2, - 1, 2, 1, 2, 0, 12, 0, 10, 0, 8, - 1, 1, 4, 1, 2, 1, 2, 0, 1, 0, - 1, 0, 1, 1, 3, 1, 1, 4, 3, 6, - 3, 4, 4, 0, 9, 1, 3, 1, 3, 3, - 5, 3, 3, 3, 3, 3, 5, 2, 1, 1, - 3, 5, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 5, 4, 3, 2, 1, 1, 3, - 3, 1, 3, 0, 1, 3, 1, 1, 1, 1, - 2, 2, 1, 2, 1, 2, 0, 4, 1, 2, - 4, 4, 4, 2, 5, 2, 1, 1, 1, 2, - 2, 2, 0, 0, 9, 3, 2, 1, 4, 2, - 3, 2, 2, 3, 2, 2, 0, 3, 2, 1, - 2, 1, 1, 4, 3, 3, 3, 3, 3, 3, - 2, 2, 2, 3, 4, 1, 3, 4, 2, 2, - 2, 2, 2, 4, 3, 2, 1, 6, 6, 3, - 6, 6, 1, 8, 8, 6, 4, 1, 6, 6, - 8, 8, 8, 6, 1, 1, 4, 1, 2, 0, - 1, 3, 1, 1, 1, 4 -}; - -/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state - STATE-NUM when YYTABLE doesn't specify something else to do. Zero - means the default is an error. */ -static const yytype_uint8 yydefact[] = -{ - 0, 3, 88, 89, 0, 33, 2, 30, 1, 0, - 0, 23, 0, 96, 183, 145, 0, 0, 131, 132, - 0, 0, 0, 182, 177, 184, 0, 162, 167, 156, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, - 45, 29, 35, 77, 94, 0, 78, 174, 175, 90, - 91, 0, 0, 0, 0, 0, 0, 0, 0, 148, - 174, 20, 21, 0, 0, 0, 0, 0, 0, 155, - 0, 0, 141, 140, 95, 142, 150, 149, 178, 107, - 24, 27, 0, 0, 0, 10, 0, 0, 0, 0, - 0, 86, 87, 0, 0, 112, 117, 0, 0, 106, - 83, 0, 129, 0, 126, 0, 0, 34, 0, 0, - 4, 6, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 76, 0, 0, 0, 0, 0, 0, 0, - 0, 152, 151, 0, 0, 0, 8, 159, 0, 0, - 0, 0, 143, 0, 47, 0, 179, 0, 0, 0, - 146, 0, 154, 0, 0, 0, 25, 28, 128, 27, - 108, 110, 111, 105, 0, 116, 0, 0, 121, 122, - 0, 124, 0, 11, 0, 119, 0, 0, 81, 84, - 103, 58, 59, 174, 125, 40, 130, 0, 38, 0, - 46, 75, 71, 70, 64, 65, 66, 67, 68, 69, - 72, 0, 5, 63, 7, 62, 0, 94, 0, 137, - 134, 135, 136, 138, 139, 60, 0, 41, 42, 9, - 79, 0, 80, 97, 144, 0, 180, 0, 0, 0, - 166, 147, 153, 0, 0, 26, 109, 0, 115, 0, - 32, 175, 0, 123, 0, 113, 12, 0, 92, 120, - 0, 0, 0, 0, 0, 0, 57, 0, 0, 0, - 0, 0, 127, 0, 37, 74, 0, 0, 0, 133, - 176, 73, 48, 98, 0, 43, 0, 94, 0, 94, - 0, 0, 0, 27, 0, 22, 185, 0, 13, 118, - 93, 85, 0, 54, 53, 55, 0, 52, 51, 82, - 100, 101, 102, 49, 0, 61, 0, 0, 181, 99, - 0, 157, 158, 161, 160, 173, 0, 165, 0, 104, - 27, 0, 0, 0, 0, 0, 0, 39, 169, 0, - 168, 0, 0, 0, 0, 94, 0, 0, 18, 0, - 56, 0, 50, 0, 0, 0, 172, 163, 164, 0, - 27, 0, 0, 171, 170, 44, 16, 0, 19, 0, - 0, 0, 114, 17, 14, 0, 15 -}; - -/* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_int16 yydefgoto[] = -{ - -1, 4, 120, 121, 225, 95, 247, 96, 365, 360, - 351, 63, 97, 98, 160, 158, 5, 239, 6, 39, - 40, 310, 41, 143, 178, 99, 54, 179, 180, 100, - 7, 249, 43, 44, 55, 275, 101, 161, 102, 174, - 287, 187, 103, 45, 46, 47, 227, 48, 104 -}; - -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -#define YYPACT_NINF -322 -static const yytype_int16 yypact[] = -{ - 680, -322, -322, -322, 25, 1583, -322, 17, -322, 34, - 34, -322, 4136, -322, -322, 39, 4490, 16, -322, -322, - 44, 63, 74, -322, -322, -322, 92, -322, -322, 255, - 102, 133, 4490, 4490, 4195, -40, -40, 4490, 811, 113, - -322, 55, 3462, -322, -322, 143, -4, -35, 76, -322, - -322, 811, 811, 1674, 62, -12, 3959, 4136, 4490, -4, - 52, -322, -322, 160, 4136, 4136, 4136, 4018, 4490, 83, - 4136, 4136, 66, 66, -322, 66, -322, -322, -322, -322, - -322, 176, 82, 82, -33, -322, 2198, 188, 190, 82, - 82, -322, -322, 2198, 199, 178, -322, 1424, 811, 3462, - 4254, 82, -322, 879, -322, 4136, 811, 1583, 117, 4136, - -322, -322, 4136, 4136, 4136, 4136, 4136, 4136, -33, 4136, - 2257, 2316, -4, 4136, 4313, 4490, 4490, 4490, 4490, 4490, - 4136, -322, -322, 4136, 947, 1015, -322, -322, 2375, 173, - 2375, 203, -322, 124, 3462, 2643, 138, 2038, 2038, 140, - -322, 149, -4, 4490, 2038, 2038, -322, 217, -322, 176, - 217, -322, -322, 212, 2139, -322, 1491, 4136, -322, -322, - 2139, -322, 4136, -322, 1424, 152, 1083, 4136, 3841, 223, - 22, -322, -4, -2, -322, -322, -322, 1424, 34, 1151, - -322, -40, 3713, -322, 3713, 3713, 3713, 3713, 3713, 3713, - -322, 2734, -322, 3633, -322, 3553, 2038, 223, 4490, 66, - 169, 169, 66, 66, 66, 3462, 21, -322, -322, -322, - 3462, -33, 3462, -322, -322, 2375, -322, 154, 2375, 2375, - -322, -322, -4, 2375, 31, -322, -322, 4136, -322, 219, - -322, -11, 2825, -322, 2825, -322, -322, 1220, -322, 224, - 155, 4372, -33, 4372, 2434, 2493, -4, 2552, 4490, 4490, - 4490, 4372, -322, 811, -322, -322, 4136, 2375, 2375, -4, - -322, -322, 3462, -322, 4, 226, 2916, 230, 3007, 231, - 1765, 189, 68, 106, -33, 226, 226, 153, -322, -322, - -322, 204, 4136, 4431, -322, -322, 3772, 4077, 3900, 3841, - -4, -4, -4, 3841, 1288, 3462, 1856, 1947, -322, -322, - 34, -322, -322, -322, -322, -322, 2375, -322, 2375, -322, - 176, 4136, 239, 245, -33, 192, 4372, -322, -322, 56, - -322, 56, 811, 3098, 3189, 247, 1558, 3280, 226, 4136, - -322, 204, 3841, 250, 258, 1356, -322, -322, -322, 239, - 176, 1424, 3371, -322, -322, -322, 226, 1558, -322, 82, - 1424, 239, -322, -322, 226, 1424, -322 -}; - -/* YYPGOTO[NTERM-NUM]. */ -static const yytype_int16 yypgoto[] = -{ - -322, -322, -146, -83, 200, -322, -322, -322, -322, -322, - -322, -322, -322, 19, -80, -153, 220, -321, -322, 174, - 171, -322, -322, -44, 14, 526, -174, -322, -322, -322, - -322, -322, -32, -60, -322, -234, -162, -29, -53, -322, - -322, -322, -13, -322, 269, -16, -322, -75, -322 -}; - -/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -32 -static const yytype_int16 yytable[] = -{ - 60, 157, 74, 250, 240, 14, 236, 133, 285, 163, - 286, 124, 14, 69, 219, 349, 60, 60, 60, 76, - 77, 60, 149, 151, 38, 8, 60, 49, 51, 52, - 136, 50, 254, 284, 130, 258, 361, 60, 134, 135, - 270, 219, 60, 200, 175, 11, 23, 24, 25, 193, - 186, 56, 60, 23, 162, 25, 64, 165, 106, 259, - 168, 169, 260, 207, 171, 2, 219, 261, 181, 3, - 37, 136, 184, 131, 132, 65, 14, 136, 139, 157, - 141, 186, 186, 60, 183, 176, 66, 319, 338, 216, - 308, 241, 156, 189, 133, 255, 159, 125, 126, 127, - 128, 14, 61, 129, 67, 62, 131, 132, 60, 60, - 60, 60, 60, 60, 70, 356, 156, 23, 325, 25, - 320, 245, 105, 186, 11, 153, 38, 364, 60, 60, - 321, 60, 60, 136, 262, 238, 186, 60, 60, 60, - 224, 243, 23, 24, 25, 71, 271, 254, 60, 136, - 254, 254, 254, 254, 60, 123, 230, 254, 136, 281, - 131, 132, 60, 136, 136, 231, 37, 336, 277, 279, - 273, 291, 146, 129, 240, 265, 60, 295, 60, 60, - 60, 60, 60, 60, 124, 60, 156, 60, 173, 60, - 60, 294, 60, 282, 289, 240, 254, 357, 136, 60, - 166, 136, 167, 157, 60, 317, 60, 263, 341, 322, - 255, 172, 191, 255, 255, 255, 255, 221, 223, 181, - 255, 181, 181, 181, 226, 181, 60, 235, 60, 181, - 237, 246, 136, 283, 290, 183, 309, 183, 183, 183, - 157, 183, 60, 60, 60, 183, 312, 314, 324, 340, - 304, 186, 323, 138, 140, 273, 60, 339, 335, 255, - 60, 107, 60, 348, 60, 293, 353, 296, 297, 298, - 157, 299, 127, 128, 354, 303, 129, 60, 190, 188, - 60, 60, 60, 60, 0, 59, 0, 60, 0, 60, - 60, 60, 186, 0, 181, 0, 0, 68, 358, 0, - 14, 72, 73, 75, 0, 0, 78, 363, 0, 0, - 183, 122, 366, 343, 0, 344, 0, 60, 60, 345, - 0, 60, 122, 0, 0, 0, 60, 75, 0, 332, - 362, 0, 0, 0, 0, 0, 60, 152, 0, 0, - 342, 23, 24, 25, 0, 0, 0, 228, 229, 0, - 0, 0, 0, 0, 233, 234, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 37, 0, 0, 122, 182, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 257, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 209, 210, 211, 212, 213, 214, 0, - 0, 0, 0, 0, 0, 0, 267, 268, 0, 0, - 0, 0, 0, 122, 122, 0, 122, 122, 0, 0, - 0, 0, 232, 122, 122, 0, 0, 274, 0, 0, - 0, 0, 0, 122, 0, 0, 0, 0, 0, 122, - 0, 0, 0, 0, 0, 0, 0, 256, 0, 0, - 140, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 122, 0, 122, 122, 122, 122, 122, 122, 0, - 122, 0, 122, 0, 122, 122, 0, 269, 0, 0, - 316, 318, 0, 0, 122, 0, 0, 0, 0, 122, - 0, 122, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 329, 331, 0, 0, - 0, 122, 0, 122, 0, 0, 0, 0, 0, 0, - 182, 0, 182, 182, 182, 140, 182, 300, 301, 302, - 182, 42, 0, 0, 0, 0, 0, 0, 53, 0, - 0, 122, 0, 0, 0, 122, 0, 122, 0, 122, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 256, 0, 0, 256, 256, 256, 256, 0, - 0, 0, 256, 0, 122, 122, 122, 0, 0, 0, - 0, 0, 144, 145, 0, 0, 0, 0, 0, 0, - 147, 148, 144, 144, 0, 182, 154, 155, 0, 0, - 0, 0, 122, 122, 0, 0, 122, 0, 0, 0, - 0, 256, 164, 0, 0, 0, 0, 0, 0, 170, - 0, 122, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 42, 0, 42, 0, 192, 0, 0, 194, 195, - 196, 197, 198, 199, 0, 201, 203, 205, 0, 206, - 0, 0, 0, 0, 0, 0, 215, 0, 0, 144, - 0, 0, 0, 0, 220, 0, 222, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - -29, 1, 0, 0, 0, 0, 0, -29, -29, 0, - 2, -29, -29, 242, 3, -29, 0, 0, 244, 0, - 0, 0, 0, 53, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, -29, -29, 0, -29, 0, - 0, 0, 0, 0, -29, -29, -29, 0, -29, 0, - -29, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 272, 0, 0, 276, 278, 0, 0, -29, 280, - 0, 0, 0, 144, 0, 0, -29, -29, -29, -29, - -29, -29, 0, 0, 0, -29, -29, -29, 0, 0, - 0, -29, -29, 0, 0, 0, -29, 0, -29, -29, - -29, 0, 305, 306, 307, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 79, 0, 0, 0, 0, 0, 53, 0, - 0, 80, 11, 12, 0, 81, 13, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 333, 0, 334, 0, 0, 337, 0, 0, - 0, 0, 0, 0, 0, 0, 14, 15, 82, 16, - 83, 84, 85, 86, 87, 352, 18, 19, 88, 20, - 0, 21, 89, 90, 0, 0, 0, 0, 0, 0, - 79, 0, 0, 0, 0, 0, 0, 91, 92, 22, - 11, 12, 0, 81, 13, 0, 185, 23, 24, 25, - 26, 27, 28, 0, 0, 0, 29, 30, 31, 93, - 94, 0, 32, 33, 0, 0, 0, 34, 0, 35, - 36, 37, 0, 0, 14, 15, 82, 16, 83, 84, - 85, 86, 87, 0, 18, 19, 88, 20, 0, 21, - 89, 90, 0, 0, 0, 0, 0, 0, 79, 0, - 0, 0, 0, 0, 0, 91, 92, 22, 11, 12, - 0, 81, 13, 0, 217, 23, 24, 25, 26, 27, - 28, 0, 0, 0, 29, 30, 31, 93, 94, 0, - 32, 33, 0, 0, 0, 34, 0, 35, 36, 37, - 0, 0, 14, 15, 82, 16, 83, 84, 85, 86, - 87, 0, 18, 19, 88, 20, 0, 21, 89, 90, - 0, 0, 0, 0, 0, 0, 79, 0, 0, 0, - 0, 0, 0, 91, 92, 22, 11, 12, 0, 81, - 13, 0, 218, 23, 24, 25, 26, 27, 28, 0, - 0, 0, 29, 30, 31, 93, 94, 0, 32, 33, - 0, 0, 0, 34, 0, 35, 36, 37, 0, 0, - 14, 15, 82, 16, 83, 84, 85, 86, 87, 0, - 18, 19, 88, 20, 0, 21, 89, 90, 0, 0, - 0, 0, 0, 0, 79, 0, 0, 0, 0, 0, - 0, 91, 92, 22, 11, 12, 0, 81, 13, 0, - 248, 23, 24, 25, 26, 27, 28, 0, 0, 0, - 29, 30, 31, 93, 94, 0, 32, 33, 0, 0, - 0, 34, 0, 35, 36, 37, 0, 0, 14, 15, - 82, 16, 83, 84, 85, 86, 87, 0, 18, 19, - 88, 20, 0, 21, 89, 90, 0, 0, 0, 0, - 0, 0, 79, 0, 0, 0, 0, 0, 0, 91, - 92, 22, 11, 12, 0, 81, 13, 0, 264, 23, - 24, 25, 26, 27, 28, 0, 0, 0, 29, 30, - 31, 93, 94, 0, 32, 33, 0, 0, 0, 34, - 0, 35, 36, 37, 0, 0, 14, 15, 82, 16, - 83, 84, 85, 86, 87, 0, 18, 19, 88, 20, - 0, 21, 89, 90, 0, 0, 0, 0, 0, 0, - 0, 79, 0, 0, 0, 0, 0, 91, 92, 22, - 288, 11, 12, 0, 81, 13, 0, 23, 24, 25, - 26, 27, 28, 0, 0, 0, 29, 30, 31, 93, - 94, 0, 32, 33, 0, 0, 0, 34, 0, 35, - 36, 37, 0, 0, 0, 14, 15, 82, 16, 83, - 84, 85, 86, 87, 0, 18, 19, 88, 20, 0, - 21, 89, 90, 0, 0, 0, 0, 0, 0, 79, - 0, 0, 0, 0, 0, 0, 91, 92, 22, 11, - 12, 0, 81, 13, 0, 327, 23, 24, 25, 26, - 27, 28, 0, 0, 0, 29, 30, 31, 93, 94, - 0, 32, 33, 0, 0, 0, 34, 0, 35, 36, - 37, 0, 0, 14, 15, 82, 16, 83, 84, 85, - 86, 87, 0, 18, 19, 88, 20, 0, 21, 89, - 90, 0, 0, 0, 0, 0, 0, 79, 0, 0, - 0, 0, 0, 0, 91, 92, 22, 11, 12, 0, - 81, 13, 0, 355, 23, 24, 25, 26, 27, 28, - 0, 0, 0, 29, 30, 31, 93, 94, 0, 32, - 33, 0, 0, 0, 34, 0, 35, 36, 37, 0, - 0, 14, 15, 82, 16, 83, 84, 85, 86, 87, - 0, 18, 19, 88, 20, 0, 21, 89, 90, 0, - 0, 0, 0, 0, 0, 79, 0, 0, 0, 0, - 0, 0, 91, 92, 22, 11, 12, 0, 81, 13, - 0, 0, 23, 24, 25, 26, 27, 28, 0, 0, - 0, 29, 30, 31, 93, 94, 0, 32, 33, 0, - 0, 0, 34, 0, 35, 36, 37, 0, 0, 14, - 15, 82, 16, 83, 84, 85, 86, 87, 0, 18, - 19, 88, 20, 0, 21, 89, 90, 0, 0, 0, - 0, 0, 79, 0, 0, 0, 0, 0, 0, 0, - 91, 92, 22, 12, 0, -31, 13, 0, 0, 0, - 23, 24, 25, 26, 27, 28, 0, 0, 0, 29, - 30, 31, 93, 94, 0, 32, 33, 0, 0, 0, - 34, 0, 35, 36, 37, 0, 14, 15, 0, 16, - 0, 84, 0, 0, 0, 0, 18, 19, 0, 20, - 0, 21, 0, 0, 0, 0, 0, 0, 0, 79, - 0, 0, 0, 0, 0, 0, 0, 91, 92, 22, - 12, 0, 0, 13, -31, 0, 0, 23, 24, 25, - 26, 27, 28, 0, 0, 0, 29, 30, 31, 0, - 9, 10, 32, 33, 11, 12, 0, 34, 13, 35, - 36, 37, 0, 14, 15, 0, 16, 0, 84, 0, - 0, 0, 0, 18, 19, 0, 20, 0, 21, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 14, 15, - 0, 16, 0, 0, 91, 92, 22, 17, 18, 19, - 0, 20, 0, 21, 23, 24, 25, 26, 27, 28, - 0, 0, 0, 29, 30, 31, 0, 0, 0, 32, - 33, 22, 0, 0, 34, 0, 35, 36, 37, 23, - 24, 25, 26, 27, 28, 0, 0, 0, 29, 30, - 31, 0, 0, 136, 32, 33, 57, 108, 0, 34, - 137, 35, 36, 37, 0, 0, 0, 109, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 110, - 111, 0, 112, 113, 114, 115, 116, 117, 118, 14, - 15, 0, 16, 0, 0, 0, 0, 0, 0, 18, - 19, 0, 20, 0, 21, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 22, 0, 0, 0, 0, 0, 0, 0, - 23, 24, 25, 26, 27, 28, 0, 119, 0, 29, - 30, 31, 0, 0, 136, 32, 33, 57, 108, 0, - 58, 315, 35, 36, 37, 0, 0, 0, 109, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 110, 111, 0, 112, 113, 114, 115, 116, 117, 118, - 14, 15, 0, 16, 0, 0, 0, 0, 0, 0, - 18, 19, 0, 20, 0, 21, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 22, 0, 0, 0, 0, 0, 0, - 0, 23, 24, 25, 26, 27, 28, 0, 119, 0, - 29, 30, 31, 0, 0, 136, 32, 33, 57, 108, - 0, 58, 328, 35, 36, 37, 0, 0, 0, 109, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 110, 111, 0, 112, 113, 114, 115, 116, 117, - 118, 14, 15, 0, 16, 0, 0, 0, 0, 0, - 0, 18, 19, 0, 20, 0, 21, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 22, 0, 0, 0, 0, 0, - 0, 0, 23, 24, 25, 26, 27, 28, 0, 119, - 0, 29, 30, 31, 0, 0, 136, 32, 33, 57, - 108, 0, 58, 330, 35, 36, 37, 0, 0, 0, - 109, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 110, 111, 0, 112, 113, 114, 115, 116, - 117, 118, 14, 15, 0, 16, 0, 0, 0, 0, - 0, 0, 18, 19, 0, 20, 0, 21, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 22, 0, 0, 0, 0, - 0, 0, 0, 23, 24, 25, 26, 27, 28, 0, - 119, 0, 29, 30, 31, 0, 0, 136, 32, 33, - 57, 108, 0, 58, 0, 35, 36, 37, 0, 0, - 0, 109, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 110, 111, 0, 112, 113, 114, 115, - 116, 117, 118, 14, 15, 0, 16, 0, 0, 0, - 0, 0, 0, 18, 19, 0, 20, 0, 21, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 22, 0, 0, 0, - 0, 0, 0, 0, 23, 24, 25, 26, 27, 28, - 0, 119, 0, 29, 30, 31, 0, 0, 0, 32, - 33, 0, 0, 0, 58, 0, 35, 36, 37, 156, - 0, 57, 108, 159, 0, 0, 0, 0, 0, 0, - 0, 0, 109, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 110, 111, 0, 112, 113, 114, - 115, 116, 117, 118, 14, 15, 0, 16, 0, 0, - 0, 0, 0, 0, 18, 19, 0, 20, 0, 21, - 0, 0, 0, 0, 0, 0, 0, 0, 156, 0, - 12, 0, 159, 13, 0, 0, 0, 22, 0, 0, - 0, 0, 0, 0, 0, 23, 24, 25, 26, 27, - 28, 0, 119, 0, 29, 30, 31, 0, 0, 0, - 32, 33, 0, 14, 15, 58, 16, 35, 36, 37, - 0, 0, 0, 18, 19, 0, 20, 0, 21, 0, - 0, 0, 0, 0, 0, 0, 0, 202, 0, 12, - 0, 0, 13, 0, 0, 0, 22, 0, 0, 0, - 0, 0, 0, 0, 23, 24, 25, 26, 27, 28, - 0, 0, 0, 29, 30, 31, 0, 0, 0, 32, - 33, 0, 14, 15, 34, 16, 35, 36, 37, 0, - 0, 0, 18, 19, 0, 20, 0, 21, 0, 0, - 0, 0, 0, 0, 0, 0, 204, 0, 12, 0, - 0, 13, 0, 0, 0, 22, 0, 0, 0, 0, - 0, 0, 0, 23, 24, 25, 26, 27, 28, 0, - 0, 0, 29, 30, 31, 0, 0, 0, 32, 33, - 0, 14, 15, 34, 16, 35, 36, 37, 0, 0, - 0, 18, 19, 0, 20, 0, 21, 0, 0, 0, - 0, 0, 0, 0, 0, 219, 0, 12, 0, 0, - 13, 0, 0, 0, 22, 0, 0, 0, 0, 0, - 0, 0, 23, 24, 25, 26, 27, 28, 0, 0, - 0, 29, 30, 31, 0, 0, 0, 32, 33, 0, - 14, 15, 34, 16, 35, 36, 37, 0, 0, 0, - 18, 19, 0, 20, 0, 21, 0, 0, 0, 0, - 0, 0, 0, 0, 202, 0, 292, 0, 0, 13, - 0, 0, 0, 22, 0, 0, 0, 0, 0, 0, - 0, 23, 24, 25, 26, 27, 28, 0, 0, 0, - 29, 30, 31, 0, 0, 0, 32, 33, 0, 14, - 15, 34, 16, 35, 36, 37, 0, 0, 0, 18, - 19, 0, 20, 0, 21, 0, 0, 0, 0, 0, - 0, 0, 0, 204, 0, 292, 0, 0, 13, 0, - 0, 0, 22, 0, 0, 0, 0, 0, 0, 0, - 23, 24, 25, 26, 27, 28, 0, 0, 0, 29, - 30, 31, 0, 0, 0, 32, 33, 0, 14, 15, - 34, 16, 35, 36, 37, 0, 0, 0, 18, 19, - 0, 20, 0, 21, 0, 0, 0, 0, 0, 0, - 0, 0, 219, 0, 292, 0, 0, 13, 0, 0, - 0, 22, 0, 0, 0, 0, 0, 0, 0, 23, - 24, 25, 26, 27, 28, 0, 0, 0, 29, 30, - 31, 0, 0, 0, 32, 33, 0, 14, 15, 34, - 16, 35, 36, 37, 0, 0, 0, 18, 19, 0, - 20, 0, 21, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 22, 0, 0, 0, 0, 0, 0, 0, 23, 24, - 25, 26, 27, 28, 0, 0, 0, 29, 30, 31, - 0, 0, 0, 32, 33, 57, 108, 0, 34, 137, - 35, 36, 37, 0, 0, 0, 109, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 110, 111, - 0, 112, 113, 114, 115, 116, 117, 118, 14, 15, - 0, 16, 0, 0, 0, 0, 0, 0, 18, 19, - 0, 20, 0, 21, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 22, 0, 0, 0, 0, 0, 0, 0, 23, - 24, 25, 26, 27, 28, 0, 119, 0, 29, 30, - 31, 0, 0, 0, 32, 33, 57, 108, 0, 58, - 0, 35, 36, 37, 0, 0, 0, 109, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 110, - 111, 0, 112, 113, 114, 115, 116, 117, 118, 14, - 15, 0, 16, 0, 0, 0, 0, 0, 0, 18, - 19, 0, 20, 0, 21, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 22, 0, 0, 0, 0, 0, 0, 0, - 23, 24, 25, 26, 27, 28, 0, 119, 266, 29, - 30, 31, 0, 0, 0, 32, 33, 57, 108, 0, - 58, 273, 35, 36, 37, 0, 0, 0, 109, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 110, 111, 0, 112, 113, 114, 115, 116, 117, 118, - 14, 15, 0, 16, 0, 0, 0, 0, 0, 0, - 18, 19, 0, 20, 0, 21, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 22, 0, 0, 0, 0, 0, 0, - 0, 23, 24, 25, 26, 27, 28, 0, 119, 0, - 29, 30, 31, 0, 0, 0, 32, 33, 57, 108, - 0, 58, 311, 35, 36, 37, 0, 0, 0, 109, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 110, 111, 0, 112, 113, 114, 115, 116, 117, - 118, 14, 15, 0, 16, 0, 0, 0, 0, 0, - 0, 18, 19, 0, 20, 0, 21, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 22, 0, 0, 0, 0, 0, - 0, 0, 23, 24, 25, 26, 27, 28, 0, 119, - 0, 29, 30, 31, 0, 0, 0, 32, 33, 57, - 108, 0, 58, 313, 35, 36, 37, 0, 0, 0, - 109, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 110, 111, 0, 112, 113, 114, 115, 116, - 117, 118, 14, 15, 0, 16, 0, 0, 0, 0, - 0, 0, 18, 19, 0, 20, 0, 21, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 22, 0, 0, 0, 0, - 0, 0, 0, 23, 24, 25, 26, 27, 28, 0, - 119, 0, 29, 30, 31, 0, 0, 0, 32, 33, - 57, 108, 0, 58, 346, 35, 36, 37, 0, 0, - 0, 109, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 110, 111, 0, 112, 113, 114, 115, - 116, 117, 118, 14, 15, 0, 16, 0, 0, 0, - 0, 0, 0, 18, 19, 0, 20, 0, 21, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 22, 0, 0, 0, - 0, 0, 0, 0, 23, 24, 25, 26, 27, 28, - 0, 119, 0, 29, 30, 31, 0, 0, 0, 32, - 33, 57, 108, 0, 58, 347, 35, 36, 37, 0, - 0, 0, 109, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 110, 111, 0, 112, 113, 114, - 115, 116, 117, 118, 14, 15, 0, 16, 0, 0, - 0, 0, 0, 0, 18, 19, 0, 20, 0, 21, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 22, 0, 0, - 0, 0, 0, 0, 0, 23, 24, 25, 26, 27, - 28, 0, 119, 0, 29, 30, 31, 0, 0, 0, - 32, 33, 57, 108, 350, 58, 0, 35, 36, 37, - 0, 0, 0, 109, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 110, 111, 0, 112, 113, - 114, 115, 116, 117, 118, 14, 15, 0, 16, 0, - 0, 0, 0, 0, 0, 18, 19, 0, 20, 0, - 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 22, 0, - 0, 0, 0, 0, 0, 0, 23, 24, 25, 26, - 27, 28, 0, 119, 0, 29, 30, 31, 0, 0, - 0, 32, 33, 57, 108, 0, 58, 359, 35, 36, - 37, 0, 0, 0, 109, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 110, 111, 0, 112, - 113, 114, 115, 116, 117, 118, 14, 15, 0, 16, - 0, 0, 0, 0, 0, 0, 18, 19, 0, 20, - 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 22, - 0, 0, 0, 0, 0, 0, 0, 23, 24, 25, - 26, 27, 28, 0, 119, 0, 29, 30, 31, 0, - 0, 0, 32, 33, 57, 108, 0, 58, 0, 35, - 36, 37, 0, 0, 0, 109, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 110, 111, 0, - 112, 113, 114, 115, 116, 117, 118, 14, 15, 0, - 16, 0, 0, 0, 0, 0, 0, 18, 19, 0, - 20, 0, 21, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 22, 0, 0, 0, 0, 0, 0, 0, 23, 24, - 25, 26, 27, 28, 0, 119, 0, 29, 30, 31, - 0, 0, 0, 32, 33, 57, 108, 0, 58, 0, - 35, 36, 37, 0, 0, 0, 109, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 110, 0, - 0, 112, 113, 114, 115, 116, 117, 118, 14, 15, - 0, 16, 0, 0, 0, 0, 0, 0, 18, 19, - 0, 20, 0, 21, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 22, 0, 0, 0, 0, 0, 0, 0, 23, - 24, 25, 26, 27, 28, 57, 108, 0, 29, 30, - 31, 0, 0, 0, 32, 33, 109, 0, 0, 58, - 0, 35, 36, 37, 0, 0, 0, 0, 0, 0, - 0, 112, 113, 114, 115, 116, 117, 118, 14, 15, - 0, 16, 0, 0, 0, 0, 0, 0, 18, 19, - 0, 20, 0, 21, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 22, 0, 0, 0, 0, 0, 0, 0, 23, - 24, 25, 26, 27, 28, 57, -32, 0, 29, 30, - 31, 0, 0, 0, 32, 33, -32, 0, 0, 58, - 0, 35, 36, 37, 0, 0, 0, 0, 0, 0, - 0, -32, -32, -32, -32, -32, -32, -32, 14, 15, - 0, 16, 0, 0, 0, 0, 0, 0, 18, 19, - 0, 20, 0, 21, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 57, 0, 0, 0, 0, 0, - 0, 22, 0, 0, 0, 251, 0, 0, 0, 23, - 24, 25, 26, 27, 28, 0, 0, 110, 111, 30, - 31, 0, 0, 0, 32, 33, 252, 14, 15, 58, - 16, 35, 36, 37, 0, 0, 0, 18, 19, 0, - 20, 0, 21, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 22, 0, 0, 57, 0, 0, 0, 0, 23, 24, - 25, 26, 27, 28, 251, 253, 326, 29, 30, 31, - 0, 0, 0, 32, 33, 0, 110, 111, 58, 0, - 35, 36, 37, 0, 0, 252, 14, 15, 0, 16, - 0, 0, 0, 0, 0, 0, 18, 19, 0, 20, - 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 57, 0, 0, 0, 0, 0, 0, 22, - 0, 0, 0, 251, 0, 0, 0, 23, 24, 25, - 26, 27, 28, 0, 253, 110, 29, 30, 31, 0, - 0, 0, 32, 33, 252, 14, 15, 58, 16, 35, - 36, 37, 0, 0, 0, 18, 19, 0, 20, 0, - 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 12, 0, 0, 13, 142, 0, 0, 22, 0, - 0, 0, 0, 0, 0, 0, 23, 24, 25, 26, - 27, 28, 0, 0, 0, 29, 30, 31, 0, 0, - 0, 32, 33, 0, 14, 15, 58, 16, 35, 36, - 37, 0, 0, 0, 18, 19, 0, 20, 0, 21, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 12, 0, 0, 13, 150, 0, 0, 22, 0, 0, - 0, 0, 0, 0, 0, 23, 24, 25, 26, 27, - 28, 0, 0, 0, 29, 30, 31, 0, 0, 0, - 32, 33, 0, 14, 15, 34, 16, 35, 36, 37, - 0, 0, 0, 18, 19, 0, 20, 0, 21, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, - 0, 0, 0, 0, 0, 0, 22, 0, 0, 0, - 251, 0, 0, 0, 23, 24, 25, 26, 27, 28, - 0, 0, 0, 29, 30, 31, 0, 0, 0, 32, - 33, 252, 14, 15, 34, 16, 35, 36, 37, 0, - 0, 0, 18, 19, 0, 20, 0, 21, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, - 0, 13, 0, 0, 0, 22, 0, 0, 0, 0, - 0, 0, 0, 23, 24, 25, 26, 27, 28, 0, - 0, 0, 29, 30, 31, 0, 0, 0, 32, 33, - 0, 14, 15, 58, 16, 35, 36, 37, 0, 0, - 0, 18, 19, 0, 20, 0, 21, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 57, 0, 0, - 13, 0, 0, 0, 22, 0, 0, 0, 0, 0, - 0, 0, 23, 24, 25, 26, 27, 28, 0, 0, - 0, 29, 30, 31, 0, 0, 0, 32, 33, 0, - 14, 15, 34, 16, 35, 36, 37, 0, 0, 0, - 18, 19, 0, 20, 0, 21, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 177, 0, 0, 13, - 0, 0, 0, 22, 0, 0, 0, 0, 0, 0, - 0, 23, 24, 25, 26, 27, 28, 0, 0, 0, - 29, 30, 31, 0, 0, 0, 32, 33, 0, 14, - 15, 34, 16, 35, 36, 37, 0, 0, 0, 18, - 19, 0, 20, 0, 21, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 57, 0, 0, 0, 0, - 0, 0, 22, 0, 0, 0, 0, 0, 0, 0, - 23, 24, 25, 26, 27, 28, 0, 0, 0, 29, - 30, 31, 0, 0, 0, 32, 33, 0, 14, 15, - 34, 16, 35, 36, 37, 0, 0, 0, 18, 19, - 0, 20, 0, 21, 0, 0, 0, 0, 0, 0, - 0, 0, 208, 0, 292, 0, 0, 13, 0, 0, - 0, 22, 0, 0, 0, 0, 0, 0, 0, 23, - 24, 25, 26, 27, 28, 0, 0, 0, 29, 30, - 31, 0, 0, 0, 32, 33, 0, 14, 15, 58, - 16, 35, 36, 37, 0, 0, 0, 18, 19, 0, - 20, 0, 21, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 57, 0, 0, 0, 0, 0, 0, - 22, 0, 0, 0, -32, 0, 0, 0, 23, 24, - 25, 26, 27, 28, 0, 0, 0, 29, 30, 31, - 0, 0, 0, 32, 33, -32, 14, 15, 34, 16, - 35, 36, 37, 0, 0, 0, 18, 19, 0, 20, - 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 57, 0, 0, 0, 0, 0, 0, 22, - 0, 0, 0, 0, 0, 0, 0, 23, 24, 25, - 26, 27, 28, 0, 0, 0, 0, 30, 31, 0, - 0, 0, 32, 33, 0, 14, 15, 58, 16, 35, - 36, 37, 0, 0, 0, 18, 19, 0, 20, 0, - 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 22, 0, - 0, 0, 0, 0, 0, 0, 23, 24, 25, 26, - 27, 28, 0, 0, 0, 29, 30, 31, 0, 0, - 0, 32, 33, 0, 0, 0, 58, 0, 35, 36, - 37 -}; - -static const yytype_int16 yycheck[] = -{ - 16, 81, 34, 177, 166, 45, 159, 18, 242, 84, - 244, 15, 45, 29, 10, 336, 32, 33, 34, 35, - 36, 37, 66, 67, 5, 0, 42, 10, 9, 10, - 9, 14, 178, 44, 69, 13, 357, 53, 51, 52, - 19, 10, 58, 118, 97, 11, 86, 87, 88, 109, - 103, 12, 68, 86, 83, 88, 12, 86, 39, 37, - 89, 90, 40, 123, 93, 10, 10, 69, 100, 14, - 110, 9, 101, 108, 109, 12, 45, 9, 16, 159, - 92, 134, 135, 99, 100, 98, 12, 19, 322, 133, - 86, 166, 10, 106, 18, 178, 14, 101, 102, 103, - 104, 45, 86, 107, 12, 89, 108, 109, 124, 125, - 126, 127, 128, 129, 12, 349, 10, 86, 292, 88, - 14, 174, 9, 176, 11, 42, 107, 361, 144, 145, - 283, 147, 148, 9, 187, 164, 189, 153, 154, 155, - 16, 170, 86, 87, 88, 12, 221, 293, 164, 9, - 296, 297, 298, 299, 170, 12, 16, 303, 9, 234, - 108, 109, 178, 9, 9, 16, 110, 320, 228, 229, - 16, 16, 12, 107, 336, 191, 192, 252, 194, 195, - 196, 197, 198, 199, 15, 201, 10, 203, 10, 205, - 206, 251, 208, 237, 247, 357, 342, 350, 9, 215, - 12, 9, 12, 283, 220, 16, 222, 188, 16, 284, - 293, 12, 95, 296, 297, 298, 299, 44, 15, 251, - 303, 253, 254, 255, 86, 257, 242, 10, 244, 261, - 18, 79, 9, 14, 10, 251, 10, 253, 254, 255, - 320, 257, 258, 259, 260, 261, 16, 16, 44, 324, - 263, 304, 99, 53, 54, 16, 272, 12, 318, 342, - 276, 41, 278, 16, 280, 251, 16, 253, 254, 255, - 350, 257, 103, 104, 16, 261, 107, 293, 107, 105, - 296, 297, 298, 299, -1, 16, -1, 303, -1, 305, - 306, 307, 345, -1, 326, -1, -1, 42, 351, -1, - 45, 32, 33, 34, -1, -1, 37, 360, -1, -1, - 326, 42, 365, 329, -1, 331, -1, 333, 334, 332, - -1, 337, 53, -1, -1, -1, 342, 58, -1, 310, - 359, -1, -1, -1, -1, -1, 352, 68, -1, -1, - 326, 86, 87, 88, -1, -1, -1, 147, 148, -1, - -1, -1, -1, -1, 154, 155, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 110, -1, -1, 99, 100, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 179, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 124, 125, 126, 127, 128, 129, -1, - -1, -1, -1, -1, -1, -1, 206, 207, -1, -1, - -1, -1, -1, 144, 145, -1, 147, 148, -1, -1, - -1, -1, 153, 154, 155, -1, -1, 227, -1, -1, - -1, -1, -1, 164, -1, -1, -1, -1, -1, 170, - -1, -1, -1, -1, -1, -1, -1, 178, -1, -1, - 250, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 192, -1, 194, 195, 196, 197, 198, 199, -1, - 201, -1, 203, -1, 205, 206, -1, 208, -1, -1, - 280, 281, -1, -1, 215, -1, -1, -1, -1, 220, - -1, 222, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 306, 307, -1, -1, - -1, 242, -1, 244, -1, -1, -1, -1, -1, -1, - 251, -1, 253, 254, 255, 325, 257, 258, 259, 260, - 261, 5, -1, -1, -1, -1, -1, -1, 12, -1, - -1, 272, -1, -1, -1, 276, -1, 278, -1, 280, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 293, -1, -1, 296, 297, 298, 299, -1, - -1, -1, 303, -1, 305, 306, 307, -1, -1, -1, - -1, -1, 56, 57, -1, -1, -1, -1, -1, -1, - 64, 65, 66, 67, -1, 326, 70, 71, -1, -1, - -1, -1, 333, 334, -1, -1, 337, -1, -1, -1, - -1, 342, 86, -1, -1, -1, -1, -1, -1, 93, - -1, 352, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 105, -1, 107, -1, 109, -1, -1, 112, 113, - 114, 115, 116, 117, -1, 119, 120, 121, -1, 123, - -1, -1, -1, -1, -1, -1, 130, -1, -1, 133, - -1, -1, -1, -1, 138, -1, 140, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 0, 1, -1, -1, -1, -1, -1, 7, 8, -1, - 10, 11, 12, 167, 14, 15, -1, -1, 172, -1, - -1, -1, -1, 177, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 45, 46, -1, 48, -1, - -1, -1, -1, -1, 54, 55, 56, -1, 58, -1, - 60, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 225, -1, -1, 228, 229, -1, -1, 78, 233, - -1, -1, -1, 237, -1, -1, 86, 87, 88, 89, - 90, 91, -1, -1, -1, 95, 96, 97, -1, -1, - -1, 101, 102, -1, -1, -1, 106, -1, 108, 109, - 110, -1, 266, 267, 268, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 1, -1, -1, -1, -1, -1, 292, -1, - -1, 10, 11, 12, -1, 14, 15, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 316, -1, 318, -1, -1, 321, -1, -1, - -1, -1, -1, -1, -1, -1, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 339, 55, 56, 57, 58, - -1, 60, 61, 62, -1, -1, -1, -1, -1, -1, - 1, -1, -1, -1, -1, -1, -1, 76, 77, 78, - 11, 12, -1, 14, 15, -1, 17, 86, 87, 88, - 89, 90, 91, -1, -1, -1, 95, 96, 97, 98, - 99, -1, 101, 102, -1, -1, -1, 106, -1, 108, - 109, 110, -1, -1, 45, 46, 47, 48, 49, 50, - 51, 52, 53, -1, 55, 56, 57, 58, -1, 60, - 61, 62, -1, -1, -1, -1, -1, -1, 1, -1, - -1, -1, -1, -1, -1, 76, 77, 78, 11, 12, - -1, 14, 15, -1, 17, 86, 87, 88, 89, 90, - 91, -1, -1, -1, 95, 96, 97, 98, 99, -1, - 101, 102, -1, -1, -1, 106, -1, 108, 109, 110, - -1, -1, 45, 46, 47, 48, 49, 50, 51, 52, - 53, -1, 55, 56, 57, 58, -1, 60, 61, 62, - -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, - -1, -1, -1, 76, 77, 78, 11, 12, -1, 14, - 15, -1, 17, 86, 87, 88, 89, 90, 91, -1, - -1, -1, 95, 96, 97, 98, 99, -1, 101, 102, - -1, -1, -1, 106, -1, 108, 109, 110, -1, -1, - 45, 46, 47, 48, 49, 50, 51, 52, 53, -1, - 55, 56, 57, 58, -1, 60, 61, 62, -1, -1, - -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, - -1, 76, 77, 78, 11, 12, -1, 14, 15, -1, - 17, 86, 87, 88, 89, 90, 91, -1, -1, -1, - 95, 96, 97, 98, 99, -1, 101, 102, -1, -1, - -1, 106, -1, 108, 109, 110, -1, -1, 45, 46, - 47, 48, 49, 50, 51, 52, 53, -1, 55, 56, - 57, 58, -1, 60, 61, 62, -1, -1, -1, -1, - -1, -1, 1, -1, -1, -1, -1, -1, -1, 76, - 77, 78, 11, 12, -1, 14, 15, -1, 17, 86, - 87, 88, 89, 90, 91, -1, -1, -1, 95, 96, - 97, 98, 99, -1, 101, 102, -1, -1, -1, 106, - -1, 108, 109, 110, -1, -1, 45, 46, 47, 48, - 49, 50, 51, 52, 53, -1, 55, 56, 57, 58, - -1, 60, 61, 62, -1, -1, -1, -1, -1, -1, - -1, 1, -1, -1, -1, -1, -1, 76, 77, 78, - 10, 11, 12, -1, 14, 15, -1, 86, 87, 88, - 89, 90, 91, -1, -1, -1, 95, 96, 97, 98, - 99, -1, 101, 102, -1, -1, -1, 106, -1, 108, - 109, 110, -1, -1, -1, 45, 46, 47, 48, 49, - 50, 51, 52, 53, -1, 55, 56, 57, 58, -1, - 60, 61, 62, -1, -1, -1, -1, -1, -1, 1, - -1, -1, -1, -1, -1, -1, 76, 77, 78, 11, - 12, -1, 14, 15, -1, 17, 86, 87, 88, 89, - 90, 91, -1, -1, -1, 95, 96, 97, 98, 99, - -1, 101, 102, -1, -1, -1, 106, -1, 108, 109, - 110, -1, -1, 45, 46, 47, 48, 49, 50, 51, - 52, 53, -1, 55, 56, 57, 58, -1, 60, 61, - 62, -1, -1, -1, -1, -1, -1, 1, -1, -1, - -1, -1, -1, -1, 76, 77, 78, 11, 12, -1, - 14, 15, -1, 17, 86, 87, 88, 89, 90, 91, - -1, -1, -1, 95, 96, 97, 98, 99, -1, 101, - 102, -1, -1, -1, 106, -1, 108, 109, 110, -1, - -1, 45, 46, 47, 48, 49, 50, 51, 52, 53, - -1, 55, 56, 57, 58, -1, 60, 61, 62, -1, - -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, - -1, -1, 76, 77, 78, 11, 12, -1, 14, 15, - -1, -1, 86, 87, 88, 89, 90, 91, -1, -1, - -1, 95, 96, 97, 98, 99, -1, 101, 102, -1, - -1, -1, 106, -1, 108, 109, 110, -1, -1, 45, - 46, 47, 48, 49, 50, 51, 52, 53, -1, 55, - 56, 57, 58, -1, 60, 61, 62, -1, -1, -1, - -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, - 76, 77, 78, 12, -1, 14, 15, -1, -1, -1, - 86, 87, 88, 89, 90, 91, -1, -1, -1, 95, - 96, 97, 98, 99, -1, 101, 102, -1, -1, -1, - 106, -1, 108, 109, 110, -1, 45, 46, -1, 48, - -1, 50, -1, -1, -1, -1, 55, 56, -1, 58, - -1, 60, -1, -1, -1, -1, -1, -1, -1, 1, - -1, -1, -1, -1, -1, -1, -1, 76, 77, 78, - 12, -1, -1, 15, 16, -1, -1, 86, 87, 88, - 89, 90, 91, -1, -1, -1, 95, 96, 97, -1, - 7, 8, 101, 102, 11, 12, -1, 106, 15, 108, - 109, 110, -1, 45, 46, -1, 48, -1, 50, -1, - -1, -1, -1, 55, 56, -1, 58, -1, 60, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 45, 46, - -1, 48, -1, -1, 76, 77, 78, 54, 55, 56, - -1, 58, -1, 60, 86, 87, 88, 89, 90, 91, - -1, -1, -1, 95, 96, 97, -1, -1, -1, 101, - 102, 78, -1, -1, 106, -1, 108, 109, 110, 86, - 87, 88, 89, 90, 91, -1, -1, -1, 95, 96, - 97, -1, -1, 9, 101, 102, 12, 13, -1, 106, - 16, 108, 109, 110, -1, -1, -1, 23, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 35, - 36, -1, 38, 39, 40, 41, 42, 43, 44, 45, - 46, -1, 48, -1, -1, -1, -1, -1, -1, 55, - 56, -1, 58, -1, 60, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 78, -1, -1, -1, -1, -1, -1, -1, - 86, 87, 88, 89, 90, 91, -1, 93, -1, 95, - 96, 97, -1, -1, 9, 101, 102, 12, 13, -1, - 106, 16, 108, 109, 110, -1, -1, -1, 23, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 35, 36, -1, 38, 39, 40, 41, 42, 43, 44, - 45, 46, -1, 48, -1, -1, -1, -1, -1, -1, - 55, 56, -1, 58, -1, 60, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 78, -1, -1, -1, -1, -1, -1, - -1, 86, 87, 88, 89, 90, 91, -1, 93, -1, - 95, 96, 97, -1, -1, 9, 101, 102, 12, 13, - -1, 106, 16, 108, 109, 110, -1, -1, -1, 23, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 35, 36, -1, 38, 39, 40, 41, 42, 43, - 44, 45, 46, -1, 48, -1, -1, -1, -1, -1, - -1, 55, 56, -1, 58, -1, 60, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 78, -1, -1, -1, -1, -1, - -1, -1, 86, 87, 88, 89, 90, 91, -1, 93, - -1, 95, 96, 97, -1, -1, 9, 101, 102, 12, - 13, -1, 106, 16, 108, 109, 110, -1, -1, -1, - 23, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 35, 36, -1, 38, 39, 40, 41, 42, - 43, 44, 45, 46, -1, 48, -1, -1, -1, -1, - -1, -1, 55, 56, -1, 58, -1, 60, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 78, -1, -1, -1, -1, - -1, -1, -1, 86, 87, 88, 89, 90, 91, -1, - 93, -1, 95, 96, 97, -1, -1, 9, 101, 102, - 12, 13, -1, 106, -1, 108, 109, 110, -1, -1, - -1, 23, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 35, 36, -1, 38, 39, 40, 41, - 42, 43, 44, 45, 46, -1, 48, -1, -1, -1, - -1, -1, -1, 55, 56, -1, 58, -1, 60, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 78, -1, -1, -1, - -1, -1, -1, -1, 86, 87, 88, 89, 90, 91, - -1, 93, -1, 95, 96, 97, -1, -1, -1, 101, - 102, -1, -1, -1, 106, -1, 108, 109, 110, 10, - -1, 12, 13, 14, -1, -1, -1, -1, -1, -1, - -1, -1, 23, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 35, 36, -1, 38, 39, 40, - 41, 42, 43, 44, 45, 46, -1, 48, -1, -1, - -1, -1, -1, -1, 55, 56, -1, 58, -1, 60, - -1, -1, -1, -1, -1, -1, -1, -1, 10, -1, - 12, -1, 14, 15, -1, -1, -1, 78, -1, -1, - -1, -1, -1, -1, -1, 86, 87, 88, 89, 90, - 91, -1, 93, -1, 95, 96, 97, -1, -1, -1, - 101, 102, -1, 45, 46, 106, 48, 108, 109, 110, - -1, -1, -1, 55, 56, -1, 58, -1, 60, -1, - -1, -1, -1, -1, -1, -1, -1, 10, -1, 12, - -1, -1, 15, -1, -1, -1, 78, -1, -1, -1, - -1, -1, -1, -1, 86, 87, 88, 89, 90, 91, - -1, -1, -1, 95, 96, 97, -1, -1, -1, 101, - 102, -1, 45, 46, 106, 48, 108, 109, 110, -1, - -1, -1, 55, 56, -1, 58, -1, 60, -1, -1, - -1, -1, -1, -1, -1, -1, 10, -1, 12, -1, - -1, 15, -1, -1, -1, 78, -1, -1, -1, -1, - -1, -1, -1, 86, 87, 88, 89, 90, 91, -1, - -1, -1, 95, 96, 97, -1, -1, -1, 101, 102, - -1, 45, 46, 106, 48, 108, 109, 110, -1, -1, - -1, 55, 56, -1, 58, -1, 60, -1, -1, -1, - -1, -1, -1, -1, -1, 10, -1, 12, -1, -1, - 15, -1, -1, -1, 78, -1, -1, -1, -1, -1, - -1, -1, 86, 87, 88, 89, 90, 91, -1, -1, - -1, 95, 96, 97, -1, -1, -1, 101, 102, -1, - 45, 46, 106, 48, 108, 109, 110, -1, -1, -1, - 55, 56, -1, 58, -1, 60, -1, -1, -1, -1, - -1, -1, -1, -1, 10, -1, 12, -1, -1, 15, - -1, -1, -1, 78, -1, -1, -1, -1, -1, -1, - -1, 86, 87, 88, 89, 90, 91, -1, -1, -1, - 95, 96, 97, -1, -1, -1, 101, 102, -1, 45, - 46, 106, 48, 108, 109, 110, -1, -1, -1, 55, - 56, -1, 58, -1, 60, -1, -1, -1, -1, -1, - -1, -1, -1, 10, -1, 12, -1, -1, 15, -1, - -1, -1, 78, -1, -1, -1, -1, -1, -1, -1, - 86, 87, 88, 89, 90, 91, -1, -1, -1, 95, - 96, 97, -1, -1, -1, 101, 102, -1, 45, 46, - 106, 48, 108, 109, 110, -1, -1, -1, 55, 56, - -1, 58, -1, 60, -1, -1, -1, -1, -1, -1, - -1, -1, 10, -1, 12, -1, -1, 15, -1, -1, - -1, 78, -1, -1, -1, -1, -1, -1, -1, 86, - 87, 88, 89, 90, 91, -1, -1, -1, 95, 96, - 97, -1, -1, -1, 101, 102, -1, 45, 46, 106, - 48, 108, 109, 110, -1, -1, -1, 55, 56, -1, - 58, -1, 60, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 78, -1, -1, -1, -1, -1, -1, -1, 86, 87, - 88, 89, 90, 91, -1, -1, -1, 95, 96, 97, - -1, -1, -1, 101, 102, 12, 13, -1, 106, 16, - 108, 109, 110, -1, -1, -1, 23, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 35, 36, - -1, 38, 39, 40, 41, 42, 43, 44, 45, 46, - -1, 48, -1, -1, -1, -1, -1, -1, 55, 56, - -1, 58, -1, 60, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 78, -1, -1, -1, -1, -1, -1, -1, 86, - 87, 88, 89, 90, 91, -1, 93, -1, 95, 96, - 97, -1, -1, -1, 101, 102, 12, 13, -1, 106, - -1, 108, 109, 110, -1, -1, -1, 23, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 35, - 36, -1, 38, 39, 40, 41, 42, 43, 44, 45, - 46, -1, 48, -1, -1, -1, -1, -1, -1, 55, - 56, -1, 58, -1, 60, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 78, -1, -1, -1, -1, -1, -1, -1, - 86, 87, 88, 89, 90, 91, -1, 93, 94, 95, - 96, 97, -1, -1, -1, 101, 102, 12, 13, -1, - 106, 16, 108, 109, 110, -1, -1, -1, 23, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 35, 36, -1, 38, 39, 40, 41, 42, 43, 44, - 45, 46, -1, 48, -1, -1, -1, -1, -1, -1, - 55, 56, -1, 58, -1, 60, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 78, -1, -1, -1, -1, -1, -1, - -1, 86, 87, 88, 89, 90, 91, -1, 93, -1, - 95, 96, 97, -1, -1, -1, 101, 102, 12, 13, - -1, 106, 16, 108, 109, 110, -1, -1, -1, 23, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 35, 36, -1, 38, 39, 40, 41, 42, 43, - 44, 45, 46, -1, 48, -1, -1, -1, -1, -1, - -1, 55, 56, -1, 58, -1, 60, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 78, -1, -1, -1, -1, -1, - -1, -1, 86, 87, 88, 89, 90, 91, -1, 93, - -1, 95, 96, 97, -1, -1, -1, 101, 102, 12, - 13, -1, 106, 16, 108, 109, 110, -1, -1, -1, - 23, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 35, 36, -1, 38, 39, 40, 41, 42, - 43, 44, 45, 46, -1, 48, -1, -1, -1, -1, - -1, -1, 55, 56, -1, 58, -1, 60, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 78, -1, -1, -1, -1, - -1, -1, -1, 86, 87, 88, 89, 90, 91, -1, - 93, -1, 95, 96, 97, -1, -1, -1, 101, 102, - 12, 13, -1, 106, 16, 108, 109, 110, -1, -1, - -1, 23, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 35, 36, -1, 38, 39, 40, 41, - 42, 43, 44, 45, 46, -1, 48, -1, -1, -1, - -1, -1, -1, 55, 56, -1, 58, -1, 60, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 78, -1, -1, -1, - -1, -1, -1, -1, 86, 87, 88, 89, 90, 91, - -1, 93, -1, 95, 96, 97, -1, -1, -1, 101, - 102, 12, 13, -1, 106, 16, 108, 109, 110, -1, - -1, -1, 23, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 35, 36, -1, 38, 39, 40, - 41, 42, 43, 44, 45, 46, -1, 48, -1, -1, - -1, -1, -1, -1, 55, 56, -1, 58, -1, 60, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 78, -1, -1, - -1, -1, -1, -1, -1, 86, 87, 88, 89, 90, - 91, -1, 93, -1, 95, 96, 97, -1, -1, -1, - 101, 102, 12, 13, 14, 106, -1, 108, 109, 110, - -1, -1, -1, 23, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 35, 36, -1, 38, 39, - 40, 41, 42, 43, 44, 45, 46, -1, 48, -1, - -1, -1, -1, -1, -1, 55, 56, -1, 58, -1, - 60, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 78, -1, - -1, -1, -1, -1, -1, -1, 86, 87, 88, 89, - 90, 91, -1, 93, -1, 95, 96, 97, -1, -1, - -1, 101, 102, 12, 13, -1, 106, 16, 108, 109, - 110, -1, -1, -1, 23, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 35, 36, -1, 38, - 39, 40, 41, 42, 43, 44, 45, 46, -1, 48, - -1, -1, -1, -1, -1, -1, 55, 56, -1, 58, - -1, 60, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 78, - -1, -1, -1, -1, -1, -1, -1, 86, 87, 88, - 89, 90, 91, -1, 93, -1, 95, 96, 97, -1, - -1, -1, 101, 102, 12, 13, -1, 106, -1, 108, - 109, 110, -1, -1, -1, 23, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 35, 36, -1, - 38, 39, 40, 41, 42, 43, 44, 45, 46, -1, - 48, -1, -1, -1, -1, -1, -1, 55, 56, -1, - 58, -1, 60, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 78, -1, -1, -1, -1, -1, -1, -1, 86, 87, - 88, 89, 90, 91, -1, 93, -1, 95, 96, 97, - -1, -1, -1, 101, 102, 12, 13, -1, 106, -1, - 108, 109, 110, -1, -1, -1, 23, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 35, -1, - -1, 38, 39, 40, 41, 42, 43, 44, 45, 46, - -1, 48, -1, -1, -1, -1, -1, -1, 55, 56, - -1, 58, -1, 60, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 78, -1, -1, -1, -1, -1, -1, -1, 86, - 87, 88, 89, 90, 91, 12, 13, -1, 95, 96, - 97, -1, -1, -1, 101, 102, 23, -1, -1, 106, - -1, 108, 109, 110, -1, -1, -1, -1, -1, -1, - -1, 38, 39, 40, 41, 42, 43, 44, 45, 46, - -1, 48, -1, -1, -1, -1, -1, -1, 55, 56, - -1, 58, -1, 60, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 78, -1, -1, -1, -1, -1, -1, -1, 86, - 87, 88, 89, 90, 91, 12, 13, -1, 95, 96, - 97, -1, -1, -1, 101, 102, 23, -1, -1, 106, - -1, 108, 109, 110, -1, -1, -1, -1, -1, -1, - -1, 38, 39, 40, 41, 42, 43, 44, 45, 46, - -1, 48, -1, -1, -1, -1, -1, -1, 55, 56, - -1, 58, -1, 60, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 12, -1, -1, -1, -1, -1, - -1, 78, -1, -1, -1, 23, -1, -1, -1, 86, - 87, 88, 89, 90, 91, -1, -1, 35, 36, 96, - 97, -1, -1, -1, 101, 102, 44, 45, 46, 106, - 48, 108, 109, 110, -1, -1, -1, 55, 56, -1, - 58, -1, 60, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 78, -1, -1, 12, -1, -1, -1, -1, 86, 87, - 88, 89, 90, 91, 23, 93, 94, 95, 96, 97, - -1, -1, -1, 101, 102, -1, 35, 36, 106, -1, - 108, 109, 110, -1, -1, 44, 45, 46, -1, 48, - -1, -1, -1, -1, -1, -1, 55, 56, -1, 58, - -1, 60, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 12, -1, -1, -1, -1, -1, -1, 78, - -1, -1, -1, 23, -1, -1, -1, 86, 87, 88, - 89, 90, 91, -1, 93, 35, 95, 96, 97, -1, - -1, -1, 101, 102, 44, 45, 46, 106, 48, 108, - 109, 110, -1, -1, -1, 55, 56, -1, 58, -1, - 60, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 12, -1, -1, 15, 16, -1, -1, 78, -1, - -1, -1, -1, -1, -1, -1, 86, 87, 88, 89, - 90, 91, -1, -1, -1, 95, 96, 97, -1, -1, - -1, 101, 102, -1, 45, 46, 106, 48, 108, 109, - 110, -1, -1, -1, 55, 56, -1, 58, -1, 60, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 12, -1, -1, 15, 16, -1, -1, 78, -1, -1, - -1, -1, -1, -1, -1, 86, 87, 88, 89, 90, - 91, -1, -1, -1, 95, 96, 97, -1, -1, -1, - 101, 102, -1, 45, 46, 106, 48, 108, 109, 110, - -1, -1, -1, 55, 56, -1, 58, -1, 60, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 12, - -1, -1, -1, -1, -1, -1, 78, -1, -1, -1, - 23, -1, -1, -1, 86, 87, 88, 89, 90, 91, - -1, -1, -1, 95, 96, 97, -1, -1, -1, 101, - 102, 44, 45, 46, 106, 48, 108, 109, 110, -1, - -1, -1, 55, 56, -1, 58, -1, 60, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 12, -1, - -1, 15, -1, -1, -1, 78, -1, -1, -1, -1, - -1, -1, -1, 86, 87, 88, 89, 90, 91, -1, - -1, -1, 95, 96, 97, -1, -1, -1, 101, 102, - -1, 45, 46, 106, 48, 108, 109, 110, -1, -1, - -1, 55, 56, -1, 58, -1, 60, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 12, -1, -1, - 15, -1, -1, -1, 78, -1, -1, -1, -1, -1, - -1, -1, 86, 87, 88, 89, 90, 91, -1, -1, - -1, 95, 96, 97, -1, -1, -1, 101, 102, -1, - 45, 46, 106, 48, 108, 109, 110, -1, -1, -1, - 55, 56, -1, 58, -1, 60, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 12, -1, -1, 15, - -1, -1, -1, 78, -1, -1, -1, -1, -1, -1, - -1, 86, 87, 88, 89, 90, 91, -1, -1, -1, - 95, 96, 97, -1, -1, -1, 101, 102, -1, 45, - 46, 106, 48, 108, 109, 110, -1, -1, -1, 55, - 56, -1, 58, -1, 60, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 12, -1, -1, -1, -1, - -1, -1, 78, -1, -1, -1, -1, -1, -1, -1, - 86, 87, 88, 89, 90, 91, -1, -1, -1, 95, - 96, 97, -1, -1, -1, 101, 102, -1, 45, 46, - 106, 48, 108, 109, 110, -1, -1, -1, 55, 56, - -1, 58, -1, 60, -1, -1, -1, -1, -1, -1, - -1, -1, 69, -1, 12, -1, -1, 15, -1, -1, - -1, 78, -1, -1, -1, -1, -1, -1, -1, 86, - 87, 88, 89, 90, 91, -1, -1, -1, 95, 96, - 97, -1, -1, -1, 101, 102, -1, 45, 46, 106, - 48, 108, 109, 110, -1, -1, -1, 55, 56, -1, - 58, -1, 60, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 12, -1, -1, -1, -1, -1, -1, - 78, -1, -1, -1, 23, -1, -1, -1, 86, 87, - 88, 89, 90, 91, -1, -1, -1, 95, 96, 97, - -1, -1, -1, 101, 102, 44, 45, 46, 106, 48, - 108, 109, 110, -1, -1, -1, 55, 56, -1, 58, - -1, 60, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 12, -1, -1, -1, -1, -1, -1, 78, - -1, -1, -1, -1, -1, -1, -1, 86, 87, 88, - 89, 90, 91, -1, -1, -1, -1, 96, 97, -1, - -1, -1, 101, 102, -1, 45, 46, 106, 48, 108, - 109, 110, -1, -1, -1, 55, 56, -1, 58, -1, - 60, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 78, -1, - -1, -1, -1, -1, -1, -1, 86, 87, 88, 89, - 90, 91, -1, -1, -1, 95, 96, 97, -1, -1, - -1, 101, 102, -1, -1, -1, 106, -1, 108, 109, - 110 -}; - -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -static const yytype_uint8 yystos[] = -{ - 0, 1, 10, 14, 113, 128, 130, 142, 0, 7, - 8, 11, 12, 15, 45, 46, 48, 54, 55, 56, - 58, 60, 78, 86, 87, 88, 89, 90, 91, 95, - 96, 97, 101, 102, 106, 108, 109, 110, 125, 131, - 132, 134, 137, 144, 145, 155, 156, 157, 159, 10, - 14, 125, 125, 137, 138, 146, 12, 12, 106, 156, - 157, 86, 89, 123, 12, 12, 12, 12, 42, 157, - 12, 12, 156, 156, 144, 156, 157, 157, 156, 1, - 10, 14, 47, 49, 50, 51, 52, 53, 57, 61, - 62, 76, 77, 98, 99, 117, 119, 124, 125, 137, - 141, 148, 150, 154, 160, 9, 125, 128, 13, 23, - 35, 36, 38, 39, 40, 41, 42, 43, 44, 93, - 114, 115, 156, 12, 15, 101, 102, 103, 104, 107, - 69, 108, 109, 18, 154, 154, 9, 16, 116, 16, - 116, 92, 16, 135, 137, 137, 12, 137, 137, 135, - 16, 135, 156, 42, 137, 137, 10, 126, 127, 14, - 126, 149, 149, 159, 137, 149, 12, 12, 149, 149, - 137, 149, 12, 10, 151, 150, 154, 12, 136, 139, - 140, 144, 156, 157, 149, 17, 150, 153, 131, 154, - 132, 95, 137, 145, 137, 137, 137, 137, 137, 137, - 159, 137, 10, 137, 10, 137, 137, 145, 69, 156, - 156, 156, 156, 156, 156, 137, 135, 17, 17, 10, - 137, 44, 137, 15, 16, 116, 86, 158, 116, 116, - 16, 16, 156, 116, 116, 10, 127, 18, 149, 129, - 148, 159, 137, 149, 137, 150, 79, 118, 17, 143, - 138, 23, 44, 93, 114, 115, 156, 116, 13, 37, - 40, 69, 150, 125, 17, 157, 94, 116, 116, 156, - 19, 159, 137, 16, 116, 147, 137, 145, 137, 145, - 137, 159, 135, 14, 44, 147, 147, 152, 10, 150, - 10, 16, 12, 136, 145, 159, 136, 136, 136, 136, - 156, 156, 156, 136, 154, 137, 137, 137, 86, 10, - 133, 16, 16, 16, 16, 16, 116, 16, 116, 19, - 14, 127, 159, 99, 44, 138, 94, 17, 16, 116, - 16, 116, 125, 137, 137, 145, 127, 137, 147, 12, - 159, 16, 136, 157, 157, 154, 16, 16, 16, 129, - 14, 122, 137, 16, 16, 17, 147, 127, 150, 16, - 121, 129, 149, 150, 147, 120, 150 -}; - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab - - -/* Like YYERROR except do call yyerror. This remains here temporarily - to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ - -#define YYFAIL goto yyerrlab - -#define YYRECOVERING() (!!yyerrstatus) - -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - yytoken = YYTRANSLATE (yychar); \ - YYPOPSTACK (1); \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (YYID (0)) - - -#define YYTERROR 1 -#define YYERRCODE 256 - - -/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. - If N is 0, then set CURRENT to the empty location which ends - the previous symbol: RHS[0] (always defined). */ - -#define YYRHSLOC(Rhs, K) ((Rhs)[K]) -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (YYID (N)) \ - { \ - (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ - (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ - } \ - else \ - { \ - (Current).first_line = (Current).last_line = \ - YYRHSLOC (Rhs, 0).last_line; \ - (Current).first_column = (Current).last_column = \ - YYRHSLOC (Rhs, 0).last_column; \ - } \ - while (YYID (0)) -#endif - - -/* YY_LOCATION_PRINT -- Print the location on the stream. - This macro was not mandated originally: define only if we know - we won't break user code: when these are the locations we know. */ - -#ifndef YY_LOCATION_PRINT -# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL -# define YY_LOCATION_PRINT(File, Loc) \ - fprintf (File, "%d.%d-%d.%d", \ - (Loc).first_line, (Loc).first_column, \ - (Loc).last_line, (Loc).last_column) -# else -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -# endif -#endif - - -/* YYLEX -- calling `yylex' with the right arguments. */ - -#ifdef YYLEX_PARAM -# define YYLEX yylex (YYLEX_PARAM) -#else -# define YYLEX yylex () -#endif - -/* Enable debugging if requested. */ -#if YYDEBUG - -# ifndef YYFPRINTF -# include /* INFRINGES ON USER NAME SPACE */ -# define YYFPRINTF fprintf -# endif - -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (YYID (0)) - -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yy_symbol_print (stderr, \ - Type, Value); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (YYID (0)) - - -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) -#else -static void -yy_symbol_value_print (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; -#endif -{ - if (!yyvaluep) - return; -# ifdef YYPRINT - if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# else - YYUSE (yyoutput); -# endif - switch (yytype) - { - default: - break; - } -} - - -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) -#else -static void -yy_symbol_print (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; -#endif -{ - if (yytype < YYNTOKENS) - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); - else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); - - yy_symbol_value_print (yyoutput, yytype, yyvaluep); - YYFPRINTF (yyoutput, ")"); -} - -/*------------------------------------------------------------------. -| yy_stack_print -- Print the state stack from its BOTTOM up to its | -| TOP (included). | -`------------------------------------------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) -#else -static void -yy_stack_print (bottom, top) - yytype_int16 *bottom; - yytype_int16 *top; -#endif -{ - YYFPRINTF (stderr, "Stack now"); - for (; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); - YYFPRINTF (stderr, "\n"); -} - -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (YYID (0)) - - -/*------------------------------------------------. -| Report that the YYRULE is going to be reduced. | -`------------------------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_reduce_print (YYSTYPE *yyvsp, int yyrule) -#else -static void -yy_reduce_print (yyvsp, yyrule) - YYSTYPE *yyvsp; - int yyrule; -#endif -{ - int yynrhs = yyr2[yyrule]; - int yyi; - unsigned long int yylno = yyrline[yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", - yyrule - 1, yylno); - /* The symbols being reduced. */ - for (yyi = 0; yyi < yynrhs; yyi++) - { - fprintf (stderr, " $%d = ", yyi + 1); - yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], - &(yyvsp[(yyi + 1) - (yynrhs)]) - ); - fprintf (stderr, "\n"); - } -} - -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (yyvsp, Rule); \ -} while (YYID (0)) - -/* Nonzero means print parse trace. It is left uninitialized so that - multiple parsers can coexist. */ -int yydebug; -#else /* !YYDEBUG */ -# define YYDPRINTF(Args) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) -# define YY_STACK_PRINT(Bottom, Top) -# define YY_REDUCE_PRINT(Rule) -#endif /* !YYDEBUG */ - - -/* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH -# define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only - if the built-in stack extension method is used). - - Do not make this value too large; the results are undefined if - YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) - evaluated with infinite-precision integer arithmetic. */ - -#ifndef YYMAXDEPTH -# define YYMAXDEPTH 10000 -#endif - - - -#if YYERROR_VERBOSE - -# ifndef yystrlen -# if defined __GLIBC__ && defined _STRING_H -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static YYSIZE_T -yystrlen (const char *yystr) -#else -static YYSIZE_T -yystrlen (yystr) - const char *yystr; -#endif -{ - YYSIZE_T yylen; - for (yylen = 0; yystr[yylen]; yylen++) - continue; - return yylen; -} -# endif -# endif - -# ifndef yystpcpy -# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static char * -yystpcpy (char *yydest, const char *yysrc) -#else -static char * -yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -#endif -{ - char *yyd = yydest; - const char *yys = yysrc; - - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -# endif -# endif - -# ifndef yytnamerr -/* Copy to YYRES the contents of YYSTR after stripping away unnecessary - quotes and backslashes, so that it's suitable for yyerror. The - heuristic is that double-quoting is unnecessary unless the string - contains an apostrophe, a comma, or backslash (other than - backslash-backslash). YYSTR is taken from yytname. If YYRES is - null, do not copy; instead, return the length of what the result - would have been. */ -static YYSIZE_T -yytnamerr (char *yyres, const char *yystr) -{ - if (*yystr == '"') - { - YYSIZE_T yyn = 0; - char const *yyp = yystr; - - for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } - do_not_strip_quotes: ; - } - - if (! yyres) - return yystrlen (yystr); - - return yystpcpy (yyres, yystr) - yyres; -} -# endif - -/* Copy into YYRESULT an error message about the unexpected token - YYCHAR while in state YYSTATE. Return the number of bytes copied, - including the terminating null byte. If YYRESULT is null, do not - copy anything; just return the number of bytes that would be - copied. As a special case, return 0 if an ordinary "syntax error" - message will do. Return YYSIZE_MAXIMUM if overflow occurs during - size calculation. */ -static YYSIZE_T -yysyntax_error (char *yyresult, int yystate, int yychar) -{ - int yyn = yypact[yystate]; - - if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) - return 0; - else - { - int yytype = YYTRANSLATE (yychar); - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); - YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; - int yysize_overflow = 0; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - int yyx; - -# if 0 - /* This is so xgettext sees the translatable formats that are - constructed on the fly. */ - YY_("syntax error, unexpected %s"); - YY_("syntax error, unexpected %s, expecting %s"); - YY_("syntax error, unexpected %s, expecting %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); -# endif - char *yyfmt; - char const *yyf; - static char const yyunexpected[] = "syntax error, unexpected %s"; - static char const yyexpecting[] = ", expecting %s"; - static char const yyor[] = " or %s"; - char yyformat[sizeof yyunexpected - + sizeof yyexpecting - 1 - + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) - * (sizeof yyor - 1))]; - char const *yyprefix = yyexpecting; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 1; - - yyarg[0] = yytname[yytype]; - yyfmt = yystpcpy (yyformat, yyunexpected); - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - yyformat[sizeof yyunexpected - 1] = '\0'; - break; - } - yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - yyfmt = yystpcpy (yyfmt, yyprefix); - yyprefix = yyor; - } - - yyf = YY_(yyformat); - yysize1 = yysize + yystrlen (yyf); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - - if (yysize_overflow) - return YYSIZE_MAXIMUM; - - if (yyresult) - { - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - char *yyp = yyresult; - int yyi = 0; - while ((*yyp = *yyf) != '\0') - { - if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyf += 2; - } - else - { - yyp++; - yyf++; - } - } - } - return yysize; - } -} -#endif /* YYERROR_VERBOSE */ - - -/*-----------------------------------------------. -| Release the memory associated to this symbol. | -`-----------------------------------------------*/ - -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) -#else -static void -yydestruct (yymsg, yytype, yyvaluep) - const char *yymsg; - int yytype; - YYSTYPE *yyvaluep; -#endif -{ - YYUSE (yyvaluep); - - if (!yymsg) - yymsg = "Deleting"; - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - - switch (yytype) - { - - default: - break; - } -} - - -/* Prevent warnings from -Wmissing-prototypes. */ - -#ifdef YYPARSE_PARAM -#if defined __STDC__ || defined __cplusplus -int yyparse (void *YYPARSE_PARAM); -#else -int yyparse (); -#endif -#else /* ! YYPARSE_PARAM */ -#if defined __STDC__ || defined __cplusplus -int yyparse (void); -#else -int yyparse (); -#endif -#endif /* ! YYPARSE_PARAM */ - - - -/* The look-ahead symbol. */ -int yychar; - -/* The semantic value of the look-ahead symbol. */ -YYSTYPE yylval; - -/* Number of syntax errors so far. */ -int yynerrs; - - - -/*----------. -| yyparse. | -`----------*/ - -#ifdef YYPARSE_PARAM -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -int -yyparse (void *YYPARSE_PARAM) -#else -int -yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -#endif -#else /* ! YYPARSE_PARAM */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -int -yyparse (void) -#else -int -yyparse () - -#endif -#endif -{ - - int yystate; - int yyn; - int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Look-ahead token as an internal (translated) token number. */ - int yytoken = 0; -#if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; -#endif - - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss = yyssa; - yytype_int16 *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - YYSTYPE *yyvsp; - - - -#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) - - YYSIZE_T yystacksize = YYINITDEPTH; - - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - - - /* The number of symbols on the RHS of the reduced rule. - Keep to zero when no symbol should be popped. */ - int yylen = 0; - - YYDPRINTF ((stderr, "Starting parse\n")); - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - - yyssp = yyss; - yyvsp = yyvs; - - goto yysetstate; - -/*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | -`------------------------------------------------------------*/ - yynewstate: - /* In all cases, when you get here, the value and location stacks - have just been pushed. So pushing a state here evens the stacks. */ - yyssp++; - - yysetstate: - *yyssp = yystate; - - if (yyss + yystacksize - 1 <= yyssp) - { - /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; - -#ifdef yyoverflow - { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; - - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - - &yystacksize); - - yyss = yyss1; - yyvs = yyvs1; - } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else - /* Extend the stack our own way. */ - if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; - yystacksize *= 2; - if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; - - { - yytype_int16 *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - -# undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); - } -# endif -#endif /* no yyoverflow */ - - yyssp = yyss + yysize - 1; - yyvsp = yyvs + yysize - 1; - - - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); - - if (yyss + yystacksize - 1 <= yyssp) - YYABORT; - } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - - goto yybackup; - -/*-----------. -| yybackup. | -`-----------*/ -yybackup: - - /* Do appropriate processing given the current state. Read a - look-ahead token if we need one and don't already have one. */ - - /* First try to decide what to do without reference to look-ahead token. */ - yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) - goto yydefault; - - /* Not known => get a look-ahead token if don't already have one. */ - - /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ - if (yychar == YYEMPTY) - { - YYDPRINTF ((stderr, "Reading a token: ")); - yychar = YYLEX; - } - - if (yychar <= YYEOF) - { - yychar = yytoken = YYEOF; - YYDPRINTF ((stderr, "Now at end of input.\n")); - } - else - { - yytoken = YYTRANSLATE (yychar); - YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); - } - - /* If the proper action on seeing token YYTOKEN is to reduce or to - detect an error, take that action. */ - yyn += yytoken; - if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) - goto yydefault; - yyn = yytable[yyn]; - if (yyn <= 0) - { - if (yyn == 0 || yyn == YYTABLE_NINF) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - - if (yyn == YYFINAL) - YYACCEPT; - - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus) - yyerrstatus--; - - /* Shift the look-ahead token. */ - YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - - /* Discard the shifted token unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; - - yystate = yyn; - *++yyvsp = yylval; - - goto yynewstate; - - -/*-----------------------------------------------------------. -| yydefault -- do the default action for the current state. | -`-----------------------------------------------------------*/ -yydefault: - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - goto yyreduce; - - -/*-----------------------------. -| yyreduce -- Do a reduction. | -`-----------------------------*/ -yyreduce: - /* yyn is the number of a rule to reduce with. */ - yylen = yyr2[yyn]; - - /* If YYLEN is nonzero, implement the default value of the action: - `$$ = $1'. - - Otherwise, the following line sets YYVAL to garbage. - This behavior is undocumented and Bison - users should not rely upon it. Assigning to YYVAL - unconditionally makes the parser a bit smaller, and it avoids a - GCC warning that YYVAL may be used uninitialized. */ - yyval = yyvsp[1-yylen]; - - - YY_REDUCE_PRINT (yyn); - switch (yyn) - { - case 2: -#line 98 "awkgram.y" - { if (errorflag==0) - winner = (Node *)stat3(PROGRAM, beginloc, (yyvsp[(1) - (1)].p), endloc); } - break; - - case 3: -#line 100 "awkgram.y" - { yyclearin; bracecheck(); SYNTAX("bailing out"); } - break; - - case 14: -#line 124 "awkgram.y" - {inloop++;} - break; - - case 15: -#line 125 "awkgram.y" - { --inloop; (yyval.p) = stat4(FOR, (yyvsp[(3) - (12)].p), notnull((yyvsp[(6) - (12)].p)), (yyvsp[(9) - (12)].p), (yyvsp[(12) - (12)].p)); } - break; - - case 16: -#line 126 "awkgram.y" - {inloop++;} - break; - - case 17: -#line 127 "awkgram.y" - { --inloop; (yyval.p) = stat4(FOR, (yyvsp[(3) - (10)].p), NIL, (yyvsp[(7) - (10)].p), (yyvsp[(10) - (10)].p)); } - break; - - case 18: -#line 128 "awkgram.y" - {inloop++;} - break; - - case 19: -#line 129 "awkgram.y" - { --inloop; (yyval.p) = stat3(IN, (yyvsp[(3) - (8)].p), makearr((yyvsp[(5) - (8)].p)), (yyvsp[(8) - (8)].p)); } - break; - - case 20: -#line 133 "awkgram.y" - { setfname((yyvsp[(1) - (1)].cp)); } - break; - - case 21: -#line 134 "awkgram.y" - { setfname((yyvsp[(1) - (1)].cp)); } - break; - - case 22: -#line 138 "awkgram.y" - { (yyval.p) = notnull((yyvsp[(3) - (4)].p)); } - break; - - case 27: -#line 150 "awkgram.y" - { (yyval.i) = 0; } - break; - - case 29: -#line 155 "awkgram.y" - { (yyval.i) = 0; } - break; - - case 31: -#line 161 "awkgram.y" - { (yyval.p) = 0; } - break; - - case 33: -#line 166 "awkgram.y" - { (yyval.p) = 0; } - break; - - case 34: -#line 167 "awkgram.y" - { (yyval.p) = (yyvsp[(2) - (3)].p); } - break; - - case 35: -#line 171 "awkgram.y" - { (yyval.p) = notnull((yyvsp[(1) - (1)].p)); } - break; - - case 36: -#line 175 "awkgram.y" - { (yyval.p) = stat2(PASTAT, (yyvsp[(1) - (1)].p), stat2(PRINT, rectonode(), NIL)); } - break; - - case 37: -#line 176 "awkgram.y" - { (yyval.p) = stat2(PASTAT, (yyvsp[(1) - (4)].p), (yyvsp[(3) - (4)].p)); } - break; - - case 38: -#line 177 "awkgram.y" - { (yyval.p) = pa2stat((yyvsp[(1) - (3)].p), (yyvsp[(3) - (3)].p), stat2(PRINT, rectonode(), NIL)); } - break; - - case 39: -#line 178 "awkgram.y" - { (yyval.p) = pa2stat((yyvsp[(1) - (6)].p), (yyvsp[(3) - (6)].p), (yyvsp[(5) - (6)].p)); } - break; - - case 40: -#line 179 "awkgram.y" - { (yyval.p) = stat2(PASTAT, NIL, (yyvsp[(2) - (3)].p)); } - break; - - case 41: -#line 181 "awkgram.y" - { beginloc = linkum(beginloc, (yyvsp[(3) - (4)].p)); (yyval.p) = 0; } - break; - - case 42: -#line 183 "awkgram.y" - { endloc = linkum(endloc, (yyvsp[(3) - (4)].p)); (yyval.p) = 0; } - break; - - case 43: -#line 184 "awkgram.y" - {infunc++;} - break; - - case 44: -#line 185 "awkgram.y" - { infunc--; curfname=0; defn((Cell *)(yyvsp[(2) - (9)].p), (yyvsp[(4) - (9)].p), (yyvsp[(8) - (9)].p)); (yyval.p) = 0; } - break; - - case 46: -#line 190 "awkgram.y" - { (yyval.p) = linkum((yyvsp[(1) - (3)].p), (yyvsp[(3) - (3)].p)); } - break; - - case 48: -#line 195 "awkgram.y" - { (yyval.p) = linkum((yyvsp[(1) - (3)].p), (yyvsp[(3) - (3)].p)); } - break; - - case 49: -#line 199 "awkgram.y" - { (yyval.p) = op2((yyvsp[(2) - (3)].i), (yyvsp[(1) - (3)].p), (yyvsp[(3) - (3)].p)); } - break; - - case 50: -#line 201 "awkgram.y" - { (yyval.p) = op3(CONDEXPR, notnull((yyvsp[(1) - (5)].p)), (yyvsp[(3) - (5)].p), (yyvsp[(5) - (5)].p)); } - break; - - case 51: -#line 203 "awkgram.y" - { (yyval.p) = op2(BOR, notnull((yyvsp[(1) - (3)].p)), notnull((yyvsp[(3) - (3)].p))); } - break; - - case 52: -#line 205 "awkgram.y" - { (yyval.p) = op2(AND, notnull((yyvsp[(1) - (3)].p)), notnull((yyvsp[(3) - (3)].p))); } - break; - - case 53: -#line 206 "awkgram.y" - { (yyval.p) = op3((yyvsp[(2) - (3)].i), NIL, (yyvsp[(1) - (3)].p), (Node*)makedfa((yyvsp[(3) - (3)].s), 0)); } - break; - - case 54: -#line 208 "awkgram.y" - { if (constnode((yyvsp[(3) - (3)].p))) - (yyval.p) = op3((yyvsp[(2) - (3)].i), NIL, (yyvsp[(1) - (3)].p), (Node*)makedfa(strnode((yyvsp[(3) - (3)].p)), 0)); - else - (yyval.p) = op3((yyvsp[(2) - (3)].i), (Node *)1, (yyvsp[(1) - (3)].p), (yyvsp[(3) - (3)].p)); } - break; - - case 55: -#line 212 "awkgram.y" - { (yyval.p) = op2(INTEST, (yyvsp[(1) - (3)].p), makearr((yyvsp[(3) - (3)].p))); } - break; - - case 56: -#line 213 "awkgram.y" - { (yyval.p) = op2(INTEST, (yyvsp[(2) - (5)].p), makearr((yyvsp[(5) - (5)].p))); } - break; - - case 57: -#line 214 "awkgram.y" - { (yyval.p) = op2(CAT, (yyvsp[(1) - (2)].p), (yyvsp[(2) - (2)].p)); } - break; - - case 60: -#line 220 "awkgram.y" - { (yyval.p) = op2((yyvsp[(2) - (3)].i), (yyvsp[(1) - (3)].p), (yyvsp[(3) - (3)].p)); } - break; - - case 61: -#line 222 "awkgram.y" - { (yyval.p) = op3(CONDEXPR, notnull((yyvsp[(1) - (5)].p)), (yyvsp[(3) - (5)].p), (yyvsp[(5) - (5)].p)); } - break; - - case 62: -#line 224 "awkgram.y" - { (yyval.p) = op2(BOR, notnull((yyvsp[(1) - (3)].p)), notnull((yyvsp[(3) - (3)].p))); } - break; - - case 63: -#line 226 "awkgram.y" - { (yyval.p) = op2(AND, notnull((yyvsp[(1) - (3)].p)), notnull((yyvsp[(3) - (3)].p))); } - break; - - case 64: -#line 227 "awkgram.y" - { (yyval.p) = op2((yyvsp[(2) - (3)].i), (yyvsp[(1) - (3)].p), (yyvsp[(3) - (3)].p)); } - break; - - case 65: -#line 228 "awkgram.y" - { (yyval.p) = op2((yyvsp[(2) - (3)].i), (yyvsp[(1) - (3)].p), (yyvsp[(3) - (3)].p)); } - break; - - case 66: -#line 229 "awkgram.y" - { (yyval.p) = op2((yyvsp[(2) - (3)].i), (yyvsp[(1) - (3)].p), (yyvsp[(3) - (3)].p)); } - break; - - case 67: -#line 230 "awkgram.y" - { (yyval.p) = op2((yyvsp[(2) - (3)].i), (yyvsp[(1) - (3)].p), (yyvsp[(3) - (3)].p)); } - break; - - case 68: -#line 231 "awkgram.y" - { (yyval.p) = op2((yyvsp[(2) - (3)].i), (yyvsp[(1) - (3)].p), (yyvsp[(3) - (3)].p)); } - break; - - case 69: -#line 232 "awkgram.y" - { (yyval.p) = op2((yyvsp[(2) - (3)].i), (yyvsp[(1) - (3)].p), (yyvsp[(3) - (3)].p)); } - break; - - case 70: -#line 233 "awkgram.y" - { (yyval.p) = op3((yyvsp[(2) - (3)].i), NIL, (yyvsp[(1) - (3)].p), (Node*)makedfa((yyvsp[(3) - (3)].s), 0)); } - break; - - case 71: -#line 235 "awkgram.y" - { if (constnode((yyvsp[(3) - (3)].p))) - (yyval.p) = op3((yyvsp[(2) - (3)].i), NIL, (yyvsp[(1) - (3)].p), (Node*)makedfa(strnode((yyvsp[(3) - (3)].p)), 0)); - else - (yyval.p) = op3((yyvsp[(2) - (3)].i), (Node *)1, (yyvsp[(1) - (3)].p), (yyvsp[(3) - (3)].p)); } - break; - - case 72: -#line 239 "awkgram.y" - { (yyval.p) = op2(INTEST, (yyvsp[(1) - (3)].p), makearr((yyvsp[(3) - (3)].p))); } - break; - - case 73: -#line 240 "awkgram.y" - { (yyval.p) = op2(INTEST, (yyvsp[(2) - (5)].p), makearr((yyvsp[(5) - (5)].p))); } - break; - - case 74: -#line 241 "awkgram.y" - { - if (safe) SYNTAX("cmd | getline is unsafe"); - else (yyval.p) = op3(GETLINE, (yyvsp[(4) - (4)].p), itonp((yyvsp[(2) - (4)].i)), (yyvsp[(1) - (4)].p)); } - break; - - case 75: -#line 244 "awkgram.y" - { - if (safe) SYNTAX("cmd | getline is unsafe"); - else (yyval.p) = op3(GETLINE, (Node*)0, itonp((yyvsp[(2) - (3)].i)), (yyvsp[(1) - (3)].p)); } - break; - - case 76: -#line 247 "awkgram.y" - { (yyval.p) = op2(CAT, (yyvsp[(1) - (2)].p), (yyvsp[(2) - (2)].p)); } - break; - - case 79: -#line 253 "awkgram.y" - { (yyval.p) = linkum((yyvsp[(1) - (3)].p), (yyvsp[(3) - (3)].p)); } - break; - - case 80: -#line 254 "awkgram.y" - { (yyval.p) = linkum((yyvsp[(1) - (3)].p), (yyvsp[(3) - (3)].p)); } - break; - - case 82: -#line 259 "awkgram.y" - { (yyval.p) = linkum((yyvsp[(1) - (3)].p), (yyvsp[(3) - (3)].p)); } - break; - - case 83: -#line 263 "awkgram.y" - { (yyval.p) = rectonode(); } - break; - - case 85: -#line 265 "awkgram.y" - { (yyval.p) = (yyvsp[(2) - (3)].p); } - break; - - case 94: -#line 282 "awkgram.y" - { (yyval.p) = op3(MATCH, NIL, rectonode(), (Node*)makedfa((yyvsp[(1) - (1)].s), 0)); } - break; - - case 95: -#line 283 "awkgram.y" - { (yyval.p) = op1(NOT, notnull((yyvsp[(2) - (2)].p))); } - break; - - case 96: -#line 287 "awkgram.y" - {startreg();} - break; - - case 97: -#line 287 "awkgram.y" - { (yyval.s) = (yyvsp[(3) - (4)].s); } - break; - - case 100: -#line 295 "awkgram.y" - { - if (safe) SYNTAX("print | is unsafe"); - else (yyval.p) = stat3((yyvsp[(1) - (4)].i), (yyvsp[(2) - (4)].p), itonp((yyvsp[(3) - (4)].i)), (yyvsp[(4) - (4)].p)); } - break; - - case 101: -#line 298 "awkgram.y" - { - if (safe) SYNTAX("print >> is unsafe"); - else (yyval.p) = stat3((yyvsp[(1) - (4)].i), (yyvsp[(2) - (4)].p), itonp((yyvsp[(3) - (4)].i)), (yyvsp[(4) - (4)].p)); } - break; - - case 102: -#line 301 "awkgram.y" - { - if (safe) SYNTAX("print > is unsafe"); - else (yyval.p) = stat3((yyvsp[(1) - (4)].i), (yyvsp[(2) - (4)].p), itonp((yyvsp[(3) - (4)].i)), (yyvsp[(4) - (4)].p)); } - break; - - case 103: -#line 304 "awkgram.y" - { (yyval.p) = stat3((yyvsp[(1) - (2)].i), (yyvsp[(2) - (2)].p), NIL, NIL); } - break; - - case 104: -#line 305 "awkgram.y" - { (yyval.p) = stat2(DELETE, makearr((yyvsp[(2) - (5)].p)), (yyvsp[(4) - (5)].p)); } - break; - - case 105: -#line 306 "awkgram.y" - { (yyval.p) = stat2(DELETE, makearr((yyvsp[(2) - (2)].p)), 0); } - break; - - case 106: -#line 307 "awkgram.y" - { (yyval.p) = exptostat((yyvsp[(1) - (1)].p)); } - break; - - case 107: -#line 308 "awkgram.y" - { yyclearin; SYNTAX("illegal statement"); } - break; - - case 110: -#line 317 "awkgram.y" - { if (!inloop) SYNTAX("break illegal outside of loops"); - (yyval.p) = stat1(BREAK, NIL); } - break; - - case 111: -#line 319 "awkgram.y" - { if (!inloop) SYNTAX("continue illegal outside of loops"); - (yyval.p) = stat1(CONTINUE, NIL); } - break; - - case 112: -#line 321 "awkgram.y" - {inloop++;} - break; - - case 113: -#line 321 "awkgram.y" - {--inloop;} - break; - - case 114: -#line 322 "awkgram.y" - { (yyval.p) = stat2(DO, (yyvsp[(3) - (9)].p), notnull((yyvsp[(7) - (9)].p))); } - break; - - case 115: -#line 323 "awkgram.y" - { (yyval.p) = stat1(EXIT, (yyvsp[(2) - (3)].p)); } - break; - - case 116: -#line 324 "awkgram.y" - { (yyval.p) = stat1(EXIT, NIL); } - break; - - case 118: -#line 326 "awkgram.y" - { (yyval.p) = stat3(IF, (yyvsp[(1) - (4)].p), (yyvsp[(2) - (4)].p), (yyvsp[(4) - (4)].p)); } - break; - - case 119: -#line 327 "awkgram.y" - { (yyval.p) = stat3(IF, (yyvsp[(1) - (2)].p), (yyvsp[(2) - (2)].p), NIL); } - break; - - case 120: -#line 328 "awkgram.y" - { (yyval.p) = (yyvsp[(2) - (3)].p); } - break; - - case 121: -#line 329 "awkgram.y" - { if (infunc) - SYNTAX("next is illegal inside a function"); - (yyval.p) = stat1(NEXT, NIL); } - break; - - case 122: -#line 332 "awkgram.y" - { if (infunc) - SYNTAX("nextfile is illegal inside a function"); - (yyval.p) = stat1(NEXTFILE, NIL); } - break; - - case 123: -#line 335 "awkgram.y" - { (yyval.p) = stat1(RETURN, (yyvsp[(2) - (3)].p)); } - break; - - case 124: -#line 336 "awkgram.y" - { (yyval.p) = stat1(RETURN, NIL); } - break; - - case 126: -#line 338 "awkgram.y" - {inloop++;} - break; - - case 127: -#line 338 "awkgram.y" - { --inloop; (yyval.p) = stat2(WHILE, (yyvsp[(1) - (3)].p), (yyvsp[(3) - (3)].p)); } - break; - - case 128: -#line 339 "awkgram.y" - { (yyval.p) = 0; } - break; - - case 130: -#line 344 "awkgram.y" - { (yyval.p) = linkum((yyvsp[(1) - (2)].p), (yyvsp[(2) - (2)].p)); } - break; - - case 133: -#line 352 "awkgram.y" - { (yyval.p) = op2(DIVEQ, (yyvsp[(1) - (4)].p), (yyvsp[(4) - (4)].p)); } - break; - - case 134: -#line 353 "awkgram.y" - { (yyval.p) = op2(ADD, (yyvsp[(1) - (3)].p), (yyvsp[(3) - (3)].p)); } - break; - - case 135: -#line 354 "awkgram.y" - { (yyval.p) = op2(MINUS, (yyvsp[(1) - (3)].p), (yyvsp[(3) - (3)].p)); } - break; - - case 136: -#line 355 "awkgram.y" - { (yyval.p) = op2(MULT, (yyvsp[(1) - (3)].p), (yyvsp[(3) - (3)].p)); } - break; - - case 137: -#line 356 "awkgram.y" - { (yyval.p) = op2(DIVIDE, (yyvsp[(1) - (3)].p), (yyvsp[(3) - (3)].p)); } - break; - - case 138: -#line 357 "awkgram.y" - { (yyval.p) = op2(MOD, (yyvsp[(1) - (3)].p), (yyvsp[(3) - (3)].p)); } - break; - - case 139: -#line 358 "awkgram.y" - { (yyval.p) = op2(POWER, (yyvsp[(1) - (3)].p), (yyvsp[(3) - (3)].p)); } - break; - - case 140: -#line 359 "awkgram.y" - { (yyval.p) = op1(UMINUS, (yyvsp[(2) - (2)].p)); } - break; - - case 141: -#line 360 "awkgram.y" - { (yyval.p) = (yyvsp[(2) - (2)].p); } - break; - - case 142: -#line 361 "awkgram.y" - { (yyval.p) = op1(NOT, notnull((yyvsp[(2) - (2)].p))); } - break; - - case 143: -#line 362 "awkgram.y" - { (yyval.p) = op2(BLTIN, itonp((yyvsp[(1) - (3)].i)), rectonode()); } - break; - - case 144: -#line 363 "awkgram.y" - { (yyval.p) = op2(BLTIN, itonp((yyvsp[(1) - (4)].i)), (yyvsp[(3) - (4)].p)); } - break; - - case 145: -#line 364 "awkgram.y" - { (yyval.p) = op2(BLTIN, itonp((yyvsp[(1) - (1)].i)), rectonode()); } - break; - - case 146: -#line 365 "awkgram.y" - { (yyval.p) = op2(CALL, celltonode((yyvsp[(1) - (3)].cp),CVAR), NIL); } - break; - - case 147: -#line 366 "awkgram.y" - { (yyval.p) = op2(CALL, celltonode((yyvsp[(1) - (4)].cp),CVAR), (yyvsp[(3) - (4)].p)); } - break; - - case 148: -#line 367 "awkgram.y" - { (yyval.p) = op1(CLOSE, (yyvsp[(2) - (2)].p)); } - break; - - case 149: -#line 368 "awkgram.y" - { (yyval.p) = op1(PREDECR, (yyvsp[(2) - (2)].p)); } - break; - - case 150: -#line 369 "awkgram.y" - { (yyval.p) = op1(PREINCR, (yyvsp[(2) - (2)].p)); } - break; - - case 151: -#line 370 "awkgram.y" - { (yyval.p) = op1(POSTDECR, (yyvsp[(1) - (2)].p)); } - break; - - case 152: -#line 371 "awkgram.y" - { (yyval.p) = op1(POSTINCR, (yyvsp[(1) - (2)].p)); } - break; - - case 153: -#line 372 "awkgram.y" - { (yyval.p) = op3(GETLINE, (yyvsp[(2) - (4)].p), itonp((yyvsp[(3) - (4)].i)), (yyvsp[(4) - (4)].p)); } - break; - - case 154: -#line 373 "awkgram.y" - { (yyval.p) = op3(GETLINE, NIL, itonp((yyvsp[(2) - (3)].i)), (yyvsp[(3) - (3)].p)); } - break; - - case 155: -#line 374 "awkgram.y" - { (yyval.p) = op3(GETLINE, (yyvsp[(2) - (2)].p), NIL, NIL); } - break; - - case 156: -#line 375 "awkgram.y" - { (yyval.p) = op3(GETLINE, NIL, NIL, NIL); } - break; - - case 157: -#line 377 "awkgram.y" - { (yyval.p) = op2(INDEX, (yyvsp[(3) - (6)].p), (yyvsp[(5) - (6)].p)); } - break; - - case 158: -#line 379 "awkgram.y" - { SYNTAX("index() doesn't permit regular expressions"); - (yyval.p) = op2(INDEX, (yyvsp[(3) - (6)].p), (Node*)(yyvsp[(5) - (6)].s)); } - break; - - case 159: -#line 381 "awkgram.y" - { (yyval.p) = (yyvsp[(2) - (3)].p); } - break; - - case 160: -#line 383 "awkgram.y" - { (yyval.p) = op3(MATCHFCN, NIL, (yyvsp[(3) - (6)].p), (Node*)makedfa((yyvsp[(5) - (6)].s), 1)); } - break; - - case 161: -#line 385 "awkgram.y" - { if (constnode((yyvsp[(5) - (6)].p))) - (yyval.p) = op3(MATCHFCN, NIL, (yyvsp[(3) - (6)].p), (Node*)makedfa(strnode((yyvsp[(5) - (6)].p)), 1)); - else - (yyval.p) = op3(MATCHFCN, (Node *)1, (yyvsp[(3) - (6)].p), (yyvsp[(5) - (6)].p)); } - break; - - case 162: -#line 389 "awkgram.y" - { (yyval.p) = celltonode((yyvsp[(1) - (1)].cp), CCON); } - break; - - case 163: -#line 391 "awkgram.y" - { (yyval.p) = op4(SPLIT, (yyvsp[(3) - (8)].p), makearr((yyvsp[(5) - (8)].p)), (yyvsp[(7) - (8)].p), (Node*)STRING); } - break; - - case 164: -#line 393 "awkgram.y" - { (yyval.p) = op4(SPLIT, (yyvsp[(3) - (8)].p), makearr((yyvsp[(5) - (8)].p)), (Node*)makedfa((yyvsp[(7) - (8)].s), 1), (Node *)REGEXPR); } - break; - - case 165: -#line 395 "awkgram.y" - { (yyval.p) = op4(SPLIT, (yyvsp[(3) - (6)].p), makearr((yyvsp[(5) - (6)].p)), NIL, (Node*)STRING); } - break; - - case 166: -#line 396 "awkgram.y" - { (yyval.p) = op1((yyvsp[(1) - (4)].i), (yyvsp[(3) - (4)].p)); } - break; - - case 167: -#line 397 "awkgram.y" - { (yyval.p) = celltonode((yyvsp[(1) - (1)].cp), CCON); } - break; - - case 168: -#line 399 "awkgram.y" - { (yyval.p) = op4((yyvsp[(1) - (6)].i), NIL, (Node*)makedfa((yyvsp[(3) - (6)].s), 1), (yyvsp[(5) - (6)].p), rectonode()); } - break; - - case 169: -#line 401 "awkgram.y" - { if (constnode((yyvsp[(3) - (6)].p))) - (yyval.p) = op4((yyvsp[(1) - (6)].i), NIL, (Node*)makedfa(strnode((yyvsp[(3) - (6)].p)), 1), (yyvsp[(5) - (6)].p), rectonode()); - else - (yyval.p) = op4((yyvsp[(1) - (6)].i), (Node *)1, (yyvsp[(3) - (6)].p), (yyvsp[(5) - (6)].p), rectonode()); } - break; - - case 170: -#line 406 "awkgram.y" - { (yyval.p) = op4((yyvsp[(1) - (8)].i), NIL, (Node*)makedfa((yyvsp[(3) - (8)].s), 1), (yyvsp[(5) - (8)].p), (yyvsp[(7) - (8)].p)); } - break; - - case 171: -#line 408 "awkgram.y" - { if (constnode((yyvsp[(3) - (8)].p))) - (yyval.p) = op4((yyvsp[(1) - (8)].i), NIL, (Node*)makedfa(strnode((yyvsp[(3) - (8)].p)), 1), (yyvsp[(5) - (8)].p), (yyvsp[(7) - (8)].p)); - else - (yyval.p) = op4((yyvsp[(1) - (8)].i), (Node *)1, (yyvsp[(3) - (8)].p), (yyvsp[(5) - (8)].p), (yyvsp[(7) - (8)].p)); } - break; - - case 172: -#line 413 "awkgram.y" - { (yyval.p) = op3(SUBSTR, (yyvsp[(3) - (8)].p), (yyvsp[(5) - (8)].p), (yyvsp[(7) - (8)].p)); } - break; - - case 173: -#line 415 "awkgram.y" - { (yyval.p) = op3(SUBSTR, (yyvsp[(3) - (6)].p), (yyvsp[(5) - (6)].p), NIL); } - break; - - case 176: -#line 421 "awkgram.y" - { (yyval.p) = op2(ARRAY, makearr((yyvsp[(1) - (4)].p)), (yyvsp[(3) - (4)].p)); } - break; - - case 177: -#line 422 "awkgram.y" - { (yyval.p) = op1(INDIRECT, celltonode((yyvsp[(1) - (1)].cp), CVAR)); } - break; - - case 178: -#line 423 "awkgram.y" - { (yyval.p) = op1(INDIRECT, (yyvsp[(2) - (2)].p)); } - break; - - case 179: -#line 427 "awkgram.y" - { arglist = (yyval.p) = 0; } - break; - - case 180: -#line 428 "awkgram.y" - { arglist = (yyval.p) = celltonode((yyvsp[(1) - (1)].cp),CVAR); } - break; - - case 181: -#line 429 "awkgram.y" - { - checkdup((yyvsp[(1) - (3)].p), (yyvsp[(3) - (3)].cp)); - arglist = (yyval.p) = linkum((yyvsp[(1) - (3)].p),celltonode((yyvsp[(3) - (3)].cp),CVAR)); } - break; - - case 182: -#line 435 "awkgram.y" - { (yyval.p) = celltonode((yyvsp[(1) - (1)].cp), CVAR); } - break; - - case 183: -#line 436 "awkgram.y" - { (yyval.p) = op1(ARG, itonp((yyvsp[(1) - (1)].i))); } - break; - - case 184: -#line 437 "awkgram.y" - { (yyval.p) = op1(VARNF, (Node *) (yyvsp[(1) - (1)].cp)); } - break; - - case 185: -#line 442 "awkgram.y" - { (yyval.p) = notnull((yyvsp[(3) - (4)].p)); } - break; - - -/* Line 1267 of yacc.c. */ -#line 3451 "y.tab.c" - default: break; - } - YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); - - YYPOPSTACK (yylen); - yylen = 0; - YY_STACK_PRINT (yyss, yyssp); - - *++yyvsp = yyval; - - - /* Now `shift' the result of the reduction. Determine what state - that goes to, based on the state we popped back to and the rule - number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; - - goto yynewstate; - - -/*------------------------------------. -| yyerrlab -- here on detecting error | -`------------------------------------*/ -yyerrlab: - /* If not already recovering from an error, report this error. */ - if (!yyerrstatus) - { - ++yynerrs; -#if ! YYERROR_VERBOSE - yyerror (YY_("syntax error")); -#else - { - YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); - if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) - { - YYSIZE_T yyalloc = 2 * yysize; - if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) - yyalloc = YYSTACK_ALLOC_MAXIMUM; - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yyalloc); - if (yymsg) - yymsg_alloc = yyalloc; - else - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - } - } - - if (0 < yysize && yysize <= yymsg_alloc) - { - (void) yysyntax_error (yymsg, yystate, yychar); - yyerror (yymsg); - } - else - { - yyerror (YY_("syntax error")); - if (yysize != 0) - goto yyexhaustedlab; - } - } -#endif - } - - - - if (yyerrstatus == 3) - { - /* If just tried and failed to reuse look-ahead token after an - error, discard it. */ - - if (yychar <= YYEOF) - { - /* Return failure if at end of input. */ - if (yychar == YYEOF) - YYABORT; - } - else - { - yydestruct ("Error: discarding", - yytoken, &yylval); - yychar = YYEMPTY; - } - } - - /* Else will try to reuse look-ahead token after shifting the error - token. */ - goto yyerrlab1; - - -/*---------------------------------------------------. -| yyerrorlab -- error raised explicitly by YYERROR. | -`---------------------------------------------------*/ -yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; - - /* Do not reclaim the symbols of the rule which action triggered - this YYERROR. */ - YYPOPSTACK (yylen); - yylen = 0; - YY_STACK_PRINT (yyss, yyssp); - yystate = *yyssp; - goto yyerrlab1; - - -/*-------------------------------------------------------------. -| yyerrlab1 -- common code for both syntax error and YYERROR. | -`-------------------------------------------------------------*/ -yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ - - for (;;) - { - yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } - - /* Pop the current state because it cannot handle the error token. */ - if (yyssp == yyss) - YYABORT; - - - yydestruct ("Error: popping", - yystos[yystate], yyvsp); - YYPOPSTACK (1); - yystate = *yyssp; - YY_STACK_PRINT (yyss, yyssp); - } - - if (yyn == YYFINAL) - YYACCEPT; - - *++yyvsp = yylval; - - - /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); - - yystate = yyn; - goto yynewstate; - - -/*-------------------------------------. -| yyacceptlab -- YYACCEPT comes here. | -`-------------------------------------*/ -yyacceptlab: - yyresult = 0; - goto yyreturn; - -/*-----------------------------------. -| yyabortlab -- YYABORT comes here. | -`-----------------------------------*/ -yyabortlab: - yyresult = 1; - goto yyreturn; - -#ifndef yyoverflow -/*-------------------------------------------------. -| yyexhaustedlab -- memory exhaustion comes here. | -`-------------------------------------------------*/ -yyexhaustedlab: - yyerror (YY_("memory exhausted")); - yyresult = 2; - /* Fall through. */ -#endif - -yyreturn: - if (yychar != YYEOF && yychar != YYEMPTY) - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval); - /* Do not reclaim the symbols of the rule which action triggered - this YYABORT or YYACCEPT. */ - YYPOPSTACK (yylen); - YY_STACK_PRINT (yyss, yyssp); - while (yyssp != yyss) - { - yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp); - YYPOPSTACK (1); - } -#ifndef yyoverflow - if (yyss != yyssa) - YYSTACK_FREE (yyss); -#endif -#if YYERROR_VERBOSE - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); -#endif - /* Make sure YYID is used. */ - return YYID (yyresult); -} - - -#line 445 "awkgram.y" - - -void setfname(Cell *p) -{ - if (isarr(p)) - SYNTAX("%s is an array, not a function", p->nval); - else if (isfcn(p)) - SYNTAX("you can't define function %s more than once", p->nval); - curfname = p->nval; -} - -int constnode(Node *p) -{ - return isvalue(p) && ((Cell *) (p->narg[0]))->csub == CCON; -} - -char *strnode(Node *p) -{ - return ((Cell *)(p->narg[0]))->sval; -} - -Node *notnull(Node *n) -{ - switch (n->nobj) { - case LE: case LT: case EQ: case NE: case GT: case GE: - case BOR: case AND: case NOT: - return n; - default: - return op2(NE, n, nullnode); - } -} - -void checkdup(Node *vl, Cell *cp) /* check if name already in list */ -{ - char *s = cp->nval; - for ( ; vl; vl = vl->nnext) { - if (strcmp(s, ((Cell *)(vl->narg[0]))->nval) == 0) { - SYNTAX("duplicate argument %s", s); - break; - } - } -} - diff --git a/commands/awk/ytabh.bak b/commands/awk/ytabh.bak deleted file mode 100644 index be63fc8d7..000000000 --- a/commands/awk/ytabh.bak +++ /dev/null @@ -1,253 +0,0 @@ -/* A Bison parser, made by GNU Bison 2.3. */ - -/* Skeleton interface for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - FIRSTTOKEN = 258, - PROGRAM = 259, - PASTAT = 260, - PASTAT2 = 261, - XBEGIN = 262, - XEND = 263, - NL = 264, - ARRAY = 265, - MATCH = 266, - NOTMATCH = 267, - MATCHOP = 268, - FINAL = 269, - DOT = 270, - ALL = 271, - CCL = 272, - NCCL = 273, - CHAR = 274, - OR = 275, - STAR = 276, - QUEST = 277, - PLUS = 278, - EMPTYRE = 279, - AND = 280, - BOR = 281, - APPEND = 282, - EQ = 283, - GE = 284, - GT = 285, - LE = 286, - LT = 287, - NE = 288, - IN = 289, - ARG = 290, - BLTIN = 291, - BREAK = 292, - CLOSE = 293, - CONTINUE = 294, - DELETE = 295, - DO = 296, - EXIT = 297, - FOR = 298, - FUNC = 299, - SUB = 300, - GSUB = 301, - IF = 302, - INDEX = 303, - LSUBSTR = 304, - MATCHFCN = 305, - NEXT = 306, - NEXTFILE = 307, - ADD = 308, - MINUS = 309, - MULT = 310, - DIVIDE = 311, - MOD = 312, - ASSIGN = 313, - ASGNOP = 314, - ADDEQ = 315, - SUBEQ = 316, - MULTEQ = 317, - DIVEQ = 318, - MODEQ = 319, - POWEQ = 320, - PRINT = 321, - PRINTF = 322, - SPRINTF = 323, - ELSE = 324, - INTEST = 325, - CONDEXPR = 326, - POSTINCR = 327, - PREINCR = 328, - POSTDECR = 329, - PREDECR = 330, - VAR = 331, - IVAR = 332, - VARNF = 333, - CALL = 334, - NUMBER = 335, - STRING = 336, - REGEXPR = 337, - GETLINE = 338, - SUBSTR = 339, - SPLIT = 340, - RETURN = 341, - WHILE = 342, - CAT = 343, - UMINUS = 344, - NOT = 345, - POWER = 346, - INCR = 347, - DECR = 348, - INDIRECT = 349, - LASTTOKEN = 350 - }; -#endif -/* Tokens. */ -#define FIRSTTOKEN 258 -#define PROGRAM 259 -#define PASTAT 260 -#define PASTAT2 261 -#define XBEGIN 262 -#define XEND 263 -#define NL 264 -#define ARRAY 265 -#define MATCH 266 -#define NOTMATCH 267 -#define MATCHOP 268 -#define FINAL 269 -#define DOT 270 -#define ALL 271 -#define CCL 272 -#define NCCL 273 -#define CHAR 274 -#define OR 275 -#define STAR 276 -#define QUEST 277 -#define PLUS 278 -#define EMPTYRE 279 -#define AND 280 -#define BOR 281 -#define APPEND 282 -#define EQ 283 -#define GE 284 -#define GT 285 -#define LE 286 -#define LT 287 -#define NE 288 -#define IN 289 -#define ARG 290 -#define BLTIN 291 -#define BREAK 292 -#define CLOSE 293 -#define CONTINUE 294 -#define DELETE 295 -#define DO 296 -#define EXIT 297 -#define FOR 298 -#define FUNC 299 -#define SUB 300 -#define GSUB 301 -#define IF 302 -#define INDEX 303 -#define LSUBSTR 304 -#define MATCHFCN 305 -#define NEXT 306 -#define NEXTFILE 307 -#define ADD 308 -#define MINUS 309 -#define MULT 310 -#define DIVIDE 311 -#define MOD 312 -#define ASSIGN 313 -#define ASGNOP 314 -#define ADDEQ 315 -#define SUBEQ 316 -#define MULTEQ 317 -#define DIVEQ 318 -#define MODEQ 319 -#define POWEQ 320 -#define PRINT 321 -#define PRINTF 322 -#define SPRINTF 323 -#define ELSE 324 -#define INTEST 325 -#define CONDEXPR 326 -#define POSTINCR 327 -#define PREINCR 328 -#define POSTDECR 329 -#define PREDECR 330 -#define VAR 331 -#define IVAR 332 -#define VARNF 333 -#define CALL 334 -#define NUMBER 335 -#define STRING 336 -#define REGEXPR 337 -#define GETLINE 338 -#define SUBSTR 339 -#define SPLIT 340 -#define RETURN 341 -#define WHILE 342 -#define CAT 343 -#define UMINUS 344 -#define NOT 345 -#define POWER 346 -#define INCR 347 -#define DECR 348 -#define INDIRECT 349 -#define LASTTOKEN 350 - - - - -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE -#line 41 "awkgram.y" -{ - Node *p; - Cell *cp; - int i; - char *s; -} -/* Line 1529 of yacc.c. */ -#line 246 "y.tab.h" - YYSTYPE; -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 -#endif - -extern YYSTYPE yylval; - diff --git a/commands/backup/Makefile b/commands/backup/Makefile new file mode 100644 index 000000000..753eec486 --- /dev/null +++ b/commands/backup/Makefile @@ -0,0 +1,6 @@ +PROG= backup +MAN= + +LINKS+= ${BINDIR}/backup ${BINDIR}/restore + +.include diff --git a/commands/simple/backup.c b/commands/backup/backup.c similarity index 100% rename from commands/simple/backup.c rename to commands/backup/backup.c diff --git a/commands/badblocks/Makefile b/commands/badblocks/Makefile new file mode 100644 index 000000000..791fa3b4c --- /dev/null +++ b/commands/badblocks/Makefile @@ -0,0 +1,5 @@ +PROG= badblocks +CPPFLAGS+= -I${MINIXSRCDIR}/servers +MAN= + +.include diff --git a/commands/simple/badblocks.c b/commands/badblocks/badblocks.c similarity index 99% rename from commands/simple/badblocks.c rename to commands/badblocks/badblocks.c index cfa1c23c0..7f38bf7ae 100644 --- a/commands/simple/badblocks.c +++ b/commands/badblocks/badblocks.c @@ -29,15 +29,15 @@ #include #include -#include "../../servers/mfs/const.h" /* must be included before stdio.h */ +#include "mfs/const.h" /* must be included before stdio.h */ #undef printf /* so its define of printf can be undone */ -#include "../../servers/mfs/type.h" +#include "mfs/type.h" #include #include #define EXTERN extern -#include "../../servers/mfs/super.h" +#include "mfs/super.h" _PROTOTYPE(int main, (int argc, char **argv)); _PROTOTYPE(void get_super, (void)); diff --git a/commands/banner/Makefile b/commands/banner/Makefile new file mode 100644 index 000000000..87989f69c --- /dev/null +++ b/commands/banner/Makefile @@ -0,0 +1,4 @@ +PROG= banner +MAN= + +.include diff --git a/commands/simple/banner.c b/commands/banner/banner.c similarity index 100% rename from commands/simple/banner.c rename to commands/banner/banner.c diff --git a/commands/basename/Makefile b/commands/basename/Makefile new file mode 100644 index 000000000..ab966c523 --- /dev/null +++ b/commands/basename/Makefile @@ -0,0 +1,4 @@ +PROG= basename +MAN= + +.include diff --git a/commands/simple/basename.c b/commands/basename/basename.c similarity index 100% rename from commands/simple/basename.c rename to commands/basename/basename.c diff --git a/commands/bigmake/Makefile b/commands/bigmake/Makefile new file mode 100644 index 000000000..d23d3edd2 --- /dev/null +++ b/commands/bigmake/Makefile @@ -0,0 +1,4 @@ +SCRIPTS= bigmake.sh +MAN= + +.include diff --git a/commands/scripts/bigmake.sh b/commands/bigmake/bigmake.sh similarity index 100% rename from commands/scripts/bigmake.sh rename to commands/bigmake/bigmake.sh diff --git a/commands/binpackage/Makefile b/commands/binpackage/Makefile new file mode 100644 index 000000000..11197820b --- /dev/null +++ b/commands/binpackage/Makefile @@ -0,0 +1,4 @@ +SCRIPTS= binpackage.sh +MAN= + +.include diff --git a/commands/scripts/binpackage.sh b/commands/binpackage/binpackage.sh similarity index 100% rename from commands/scripts/binpackage.sh rename to commands/binpackage/binpackage.sh diff --git a/commands/binpackages/Makefile b/commands/binpackages/Makefile new file mode 100644 index 000000000..079bce1d3 --- /dev/null +++ b/commands/binpackages/Makefile @@ -0,0 +1,4 @@ +SCRIPTS= binpackages.sh +MAN= + +.include diff --git a/commands/scripts/binpackages.sh b/commands/binpackages/binpackages.sh similarity index 100% rename from commands/scripts/binpackages.sh rename to commands/binpackages/binpackages.sh diff --git a/commands/binsizes/Makefile b/commands/binsizes/Makefile new file mode 100644 index 000000000..949419481 --- /dev/null +++ b/commands/binsizes/Makefile @@ -0,0 +1,4 @@ +SCRIPTS= binsizes.sh +MAN= + +.include diff --git a/commands/scripts/binsizes.sh b/commands/binsizes/binsizes.sh similarity index 100% rename from commands/scripts/binsizes.sh rename to commands/binsizes/binsizes.sh diff --git a/commands/byacc/MANIFEST b/commands/byacc/MANIFEST deleted file mode 100644 index f4f918e1f..000000000 --- a/commands/byacc/MANIFEST +++ /dev/null @@ -1,33 +0,0 @@ - File Name Archive # Description ------------------------------------------------------------ - ACKNOWLEDGEMENTS 1 - CSU.diffs 1 - MANIFEST 1 This shipping list - Makefile 1 - NEW_FEATURES 1 - NOTES 1 - NO_WARRANTY 1 - README 1 - closure.c 1 - defs.h 1 - error.c 1 - lalr.c 1 - lr0.c 1 - main.c 1 - mkpar.c 1 - output.c 2 - reader.c 3 - skeleton.c 1 - symtab.c 1 - test 1 - test/error.output 1 - test/error.tab.c 1 - test/error.tab.h 1 - test/error.y 1 - test/ftp.output 2 - test/ftp.tab.c 3 - test/ftp.tab.h 1 - test/ftp.y 2 - verbose.c 1 - warshall.c 1 - yacc.1 1 diff --git a/commands/byacc/Makefile b/commands/byacc/Makefile deleted file mode 100644 index c36e7028b..000000000 --- a/commands/byacc/Makefile +++ /dev/null @@ -1,86 +0,0 @@ -# Makefile for Berkeley yacc. - -BINDIR = /usr/bin - -HDRS = defs.h - -CFLAGS = -DNDEBUG -D_MINIX -D_POSIX_SOURCE -wo $(OPT) - -LDFLAGS = -i - -LIBS = - -CC = exec cc - -LINKER = $(CC) - -MAKEFILE = Makefile - -OBJS = closure.o \ - error.o \ - lalr.o \ - lr0.o \ - main.o \ - mkpar.o \ - output.o \ - reader.o \ - skeleton.o \ - symtab.o \ - verbose.o \ - warshall.o - -PRINT = pr -f -l88 - -PROGRAM = yacc - -SRCS = closure.c \ - error.c \ - lalr.c \ - lr0.c \ - main.c \ - mkpar.c \ - output.c \ - reader.c \ - skeleton.c \ - symtab.c \ - verbose.c \ - warshall.c - -all: $(PROGRAM) - -$(PROGRAM): $(OBJS) $(LIBS) - $(LINKER) $(LDFLAGS) -o $(PROGRAM) $(OBJS) $(LIBS) - install -S 484k $(PROGRAM) - -install: $(BINDIR)/yacc - -$(BINDIR)/yacc: $(PROGRAM) - install -cs -o bin $(PROGRAM) $@ - -clean:; rm -f $(OBJS) $(PROGRAM) core - -#depend:; @mkmf -f $(MAKEFILE) PROGRAM=$(PROGRAM) DEST=$(DEST) -# -#index:; @ctags -wx $(HDRS) $(SRCS) -# -#listing:; @$(PRINT) Makefile $(HDRS) $(SRCS) | lpr -# -#lint:; @lint $(SRCS) -# -#program: $(PROGRAM) -# -#tags: $(HDRS) $(SRCS); @ctags $(HDRS) $(SRCS) - -### -closure.o: defs.h -error.o: defs.h -lalr.o: defs.h -lr0.o: defs.h -main.o: defs.h -mkpar.o: defs.h -output.o: defs.h -reader.o: defs.h -skeleton.o: defs.h -symtab.o: defs.h -verbose.o: defs.h -warshall.o: defs.h diff --git a/commands/byacc/NOTES b/commands/byacc/NOTES deleted file mode 100644 index 9db3c96ce..000000000 --- a/commands/byacc/NOTES +++ /dev/null @@ -1,9 +0,0 @@ -Berkeley Yacc reflects its origins. The reason so many routines -use exactly six register variables is that Berkeley Yacc was -developed on a VAX using PCC. PCC placed at most six variables -in registers. I went to considerable effort to find which six -variables most belonged in registers. Changes in machines and -compilers make that effort worthless, perhaps even harmful. - -The code contains many instances where address calculations are -performed in particular ways to optimize the code for the VAX. diff --git a/commands/byacc/NO_WARRANTY b/commands/byacc/NO_WARRANTY deleted file mode 100644 index 06e8d93a2..000000000 --- a/commands/byacc/NO_WARRANTY +++ /dev/null @@ -1,3 +0,0 @@ - Berkeley Yacc is distributed with no warranty whatever. The author -and any other contributors take no responsibility for the consequences of -its use. diff --git a/commands/byacc/build b/commands/byacc/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/byacc/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/byacc/main.c b/commands/byacc/main.c deleted file mode 100644 index e6d0d7ead..000000000 --- a/commands/byacc/main.c +++ /dev/null @@ -1,378 +0,0 @@ -#include -#include -#include "defs.h" - -char dflag; -char lflag; -char rflag; -char tflag; -char vflag; - -char *symbol_prefix; -char *file_prefix = "y"; -char *myname = "yacc"; -char *temp_form = "yacc.XXXXXXX"; - -int lineno; -int outline; - -char *action_file_name; -char *code_file_name; -char *defines_file_name; -char *input_file_name = ""; -char *output_file_name; -char *text_file_name; -char *union_file_name; -char *verbose_file_name; - -FILE *action_file; /* a temp file, used to save actions associated */ - /* with rules until the parser is written */ -FILE *code_file; /* y.code.c (used when the -r option is specified) */ -FILE *defines_file; /* y.tab.h */ -FILE *input_file; /* the input file */ -FILE *output_file; /* y.tab.c */ -FILE *text_file; /* a temp file, used to save text until all */ - /* symbols have been defined */ -FILE *union_file; /* a temp file, used to save the union */ - /* definition until all symbol have been */ - /* defined */ -FILE *verbose_file; /* y.output */ - -int nitems; -int nrules; -int nsyms; -int ntokens; -int nvars; - -int start_symbol; -char **symbol_name; -short *symbol_value; -short *symbol_prec; -char *symbol_assoc; - -short *ritem; -short *rlhs; -short *rrhs; -short *rprec; -char *rassoc; -short **derives; -char *nullable; - -extern char *mktemp(); -extern char *getenv(); - - -done(k) -int k; -{ - if (action_file) { fclose(action_file); unlink(action_file_name); } - if (text_file) { fclose(text_file); unlink(text_file_name); } - if (union_file) { fclose(union_file); unlink(union_file_name); } - exit(k); -} - - -void -onintr(signo) - int signo; -{ - done(1); -} - - -set_signals() -{ -#ifdef SIGINT - if (signal(SIGINT, SIG_IGN) != SIG_IGN) - signal(SIGINT, onintr); -#endif -#ifdef SIGTERM - if (signal(SIGTERM, SIG_IGN) != SIG_IGN) - signal(SIGTERM, onintr); -#endif -#ifdef SIGHUP - if (signal(SIGHUP, SIG_IGN) != SIG_IGN) - signal(SIGHUP, onintr); -#endif -} - - -usage() -{ - fprintf(stderr, "usage: %s [-dlrtv] [-b file_prefix] [-p symbol_prefix] filename\n", myname); - exit(1); -} - - -getargs(argc, argv) -int argc; -char *argv[]; -{ - register int i; - register char *s; - - if (argc > 0) myname = argv[0]; - for (i = 1; i < argc; ++i) - { - s = argv[i]; - if (*s != '-') break; - switch (*++s) - { - case '\0': - input_file = stdin; - if (i + 1 < argc) usage(); - return; - - case '-': - ++i; - goto no_more_options; - - case 'b': - if (*++s) - file_prefix = s; - else if (++i < argc) - file_prefix = argv[i]; - else - usage(); - continue; - - case 'd': - dflag = 1; - break; - - case 'l': - lflag = 1; - break; - - case 'p': - if (*++s) - symbol_prefix = s; - else if (++i < argc) - symbol_prefix = argv[i]; - else - usage(); - continue; - - case 'r': - rflag = 1; - break; - - case 't': - tflag = 1; - break; - - case 'v': - vflag = 1; - break; - - default: - usage(); - } - - for (;;) - { - switch (*++s) - { - case '\0': - goto end_of_option; - - case 'd': - dflag = 1; - break; - - case 'l': - lflag = 1; - break; - - case 'r': - rflag = 1; - break; - - case 't': - tflag = 1; - break; - - case 'v': - vflag = 1; - break; - - default: - usage(); - } - } -end_of_option:; - } - -no_more_options:; - if (i + 1 != argc) usage(); - input_file_name = argv[i]; -} - - -char * -allocate(n) -unsigned n; -{ - register char *p; - - p = NULL; - if (n) - { - p = CALLOC(1, n); - if (!p) no_space(); - } - return (p); -} - - -create_file_names() -{ - int i, len; - char *tmpdir; - - tmpdir = getenv("TMPDIR"); - if (tmpdir == 0) tmpdir = "/tmp"; - - len = strlen(tmpdir); - i = len + 13; - if (len && tmpdir[len-1] != '/') - ++i; - - action_file_name = MALLOC(i); - if (action_file_name == 0) no_space(); - text_file_name = MALLOC(i); - if (text_file_name == 0) no_space(); - union_file_name = MALLOC(i); - if (union_file_name == 0) no_space(); - - strcpy(action_file_name, tmpdir); - strcpy(text_file_name, tmpdir); - strcpy(union_file_name, tmpdir); - - if (len && tmpdir[len - 1] != '/') - { - action_file_name[len] = '/'; - text_file_name[len] = '/'; - union_file_name[len] = '/'; - ++len; - } - - strcpy(action_file_name + len, temp_form); - strcpy(text_file_name + len, temp_form); - strcpy(union_file_name + len, temp_form); - - action_file_name[len + 5] = 'a'; - text_file_name[len + 5] = 't'; - union_file_name[len + 5] = 'u'; - - mktemp(action_file_name); - mktemp(text_file_name); - mktemp(union_file_name); - - len = strlen(file_prefix); - - output_file_name = MALLOC(len + 7); - if (output_file_name == 0) - no_space(); - strcpy(output_file_name, file_prefix); - strcpy(output_file_name + len, OUTPUT_SUFFIX); - - if (rflag) - { - code_file_name = MALLOC(len + 8); - if (code_file_name == 0) - no_space(); - strcpy(code_file_name, file_prefix); - strcpy(code_file_name + len, CODE_SUFFIX); - } - else - code_file_name = output_file_name; - - if (dflag) - { - defines_file_name = MALLOC(len + 7); - if (defines_file_name == 0) - no_space(); - strcpy(defines_file_name, file_prefix); - strcpy(defines_file_name + len, DEFINES_SUFFIX); - } - - if (vflag) - { - verbose_file_name = MALLOC(len + 8); - if (verbose_file_name == 0) - no_space(); - strcpy(verbose_file_name, file_prefix); - strcpy(verbose_file_name + len, VERBOSE_SUFFIX); - } -} - - -open_files() -{ - create_file_names(); - - if (input_file == 0) - { - input_file = fopen(input_file_name, "r"); - if (input_file == 0) - open_error(input_file_name); - } - - action_file = fopen(action_file_name, "w"); - if (action_file == 0) - open_error(action_file_name); - - text_file = fopen(text_file_name, "w"); - if (text_file == 0) - open_error(text_file_name); - - if (vflag) - { - verbose_file = fopen(verbose_file_name, "w"); - if (verbose_file == 0) - open_error(verbose_file_name); - } - - if (dflag) - { - defines_file = fopen(defines_file_name, "w"); - if (defines_file == 0) - open_error(defines_file_name); - union_file = fopen(union_file_name, "w"); - if (union_file == 0) - open_error(union_file_name); - } - - output_file = fopen(output_file_name, "w"); - if (output_file == 0) - open_error(output_file_name); - - if (rflag) - { - code_file = fopen(code_file_name, "w"); - if (code_file == 0) - open_error(code_file_name); - } - else - code_file = output_file; -} - - -int -main(argc, argv) -int argc; -char *argv[]; -{ - set_signals(); - getargs(argc, argv); - open_files(); - reader(); - lr0(); - lalr(); - make_parser(); - verbose(); - output(); - done(0); - /*NOTREACHED*/ -} diff --git a/commands/byacc/symtab.c b/commands/byacc/symtab.c deleted file mode 100644 index c7c6ac03a..000000000 --- a/commands/byacc/symtab.c +++ /dev/null @@ -1,119 +0,0 @@ -#include "defs.h" - - -/* TABLE_SIZE is the number of entries in the symbol table. */ -/* TABLE_SIZE must be a power of two. */ - -#define TABLE_SIZE 1024 - - -bucket **symbol_table; -bucket *first_symbol; -bucket *last_symbol; - - -int -hash(name) -char *name; -{ - register char *s; - register int c, k; - - assert(name && *name); - s = name; - k = *s; - while (c = *++s) - k = (31*k + c) & (TABLE_SIZE - 1); - - return (k); -} - - -bucket * -make_bucket(name) -char *name; -{ - register bucket *bp; - - assert(name); - bp = (bucket *) MALLOC(sizeof(bucket)); - if (bp == 0) no_space(); - bp->link = 0; - bp->next = 0; - bp->name = MALLOC(strlen(name) + 1); - if (bp->name == 0) no_space(); - bp->tag = 0; - bp->value = UNDEFINED; - bp->index = 0; - bp->prec = 0; - bp-> class = UNKNOWN; - bp->assoc = TOKEN; - - if (bp->name == 0) no_space(); - strcpy(bp->name, name); - - return (bp); -} - - -bucket * -lookup(name) -char *name; -{ - register bucket *bp, **bpp; - - bpp = symbol_table + hash(name); - bp = *bpp; - - while (bp) - { - if (strcmp(name, bp->name) == 0) return (bp); - bpp = &bp->link; - bp = *bpp; - } - - *bpp = bp = make_bucket(name); - last_symbol->next = bp; - last_symbol = bp; - - return (bp); -} - - -create_symbol_table() -{ - register int i; - register bucket *bp; - - symbol_table = (bucket **) MALLOC(TABLE_SIZE*sizeof(bucket *)); - if (symbol_table == 0) no_space(); - for (i = 0; i < TABLE_SIZE; i++) - symbol_table[i] = 0; - - bp = make_bucket("error"); - bp->index = 1; - bp->class = TERM; - - first_symbol = bp; - last_symbol = bp; - symbol_table[hash("error")] = bp; -} - - -free_symbol_table() -{ - FREE(symbol_table); - symbol_table = 0; -} - - -free_symbols() -{ - register bucket *p, *q; - - for (p = first_symbol; p; p = q) - { - q = p->next; - FREE(p); - } -} diff --git a/commands/byacc/warshall.c b/commands/byacc/warshall.c deleted file mode 100644 index b449e4e27..000000000 --- a/commands/byacc/warshall.c +++ /dev/null @@ -1,82 +0,0 @@ -#include "defs.h" - -transitive_closure(R, n) -unsigned *R; -int n; -{ - register int rowsize; - register unsigned i; - register unsigned *rowj; - register unsigned *rp; - register unsigned *rend; - register unsigned *ccol; - register unsigned *relend; - register unsigned *cword; - register unsigned *rowi; - - rowsize = WORDSIZE(n); - relend = R + n*rowsize; - - cword = R; - i = 0; - rowi = R; - while (rowi < relend) - { - ccol = cword; - rowj = R; - - while (rowj < relend) - { - if (*ccol & (1 << i)) - { - rp = rowi; - rend = rowj + rowsize; - while (rowj < rend) - *rowj++ |= *rp++; - } - else - { - rowj += rowsize; - } - - ccol += rowsize; - } - - if (++i >= BITS_PER_WORD) - { - i = 0; - cword++; - } - - rowi += rowsize; - } -} - -reflexive_transitive_closure(R, n) -unsigned *R; -int n; -{ - register int rowsize; - register unsigned i; - register unsigned *rp; - register unsigned *relend; - - transitive_closure(R, n); - - rowsize = WORDSIZE(n); - relend = R + n*rowsize; - - i = 0; - rp = R; - while (rp < relend) - { - *rp |= (1 << i); - if (++i >= BITS_PER_WORD) - { - i = 0; - rp++; - } - - rp += rowsize; - } -} diff --git a/commands/bzip2-1.0.3/README.MINIX b/commands/bzip2-1.0.3/README.MINIX deleted file mode 100644 index a03e17d16..000000000 --- a/commands/bzip2-1.0.3/README.MINIX +++ /dev/null @@ -1,172 +0,0 @@ -############################################################################### -# Quick installation -############################################################################### - -To build and install bzip into /usr/local, execute the following commands -as user bin: - -make -make install - -To install into another directory use: -make install PREFIX= - -############################################################################### -# bzip 1.0.3 for Minix -############################################################################### -The text below is taken from the original README file. The original file is -available as README.ORIGINAL. - -This is the README for bzip2, a block-sorting file compressor, version -1.0.3. This version is fully compatible with the previous public -releases, versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1 and 1.0.2. - -bzip2-1.0.3 is distributed under a BSD-style license. For details, -see the file LICENSE. - -Complete documentation is available in Postscript form (manual.ps), -PDF (manual.pdf) or html (manual.html). A plain-text version of the -manual page is available as bzip2.txt. A statement about Y2K issues -is now included in the file Y2K_INFO. - - -HOW TO BUILD -- MINIX - -Type `make'. This builds the library libbz2.a and then the -programs bzip2 and bzip2recover. Six self-tests are run. -If the self-tests complete ok, carry on to installation: - -To install in /usr/local/bin, /usr/local/lib, /usr/local/man and - /usr/local/include, type - make install -To install somewhere else, eg, /xxx/yyy/{bin,lib,man,include}, type - make install PREFIX=/xxx/yyy -If you are (justifiably) paranoid and want to see what 'make install' -is going to do, you can first do - make -n install or - make -n install PREFIX=/xxx/yyy respectively. -The -n instructs make to show the commands it would execute, but -not actually execute them. - -VALIDATION - -Correct operation, in the sense that a compressed file can always be -decompressed to reproduce the original, is obviously of paramount -importance. To validate bzip2, I used a modified version of Mark -Nelson's churn program. Churn is an automated test driver which -recursively traverses a directory structure, using bzip2 to compress -and then decompress each file it encounters, and checking that the -decompressed data is the same as the original. - - - -Please read and be aware of the following: - -WARNING: - - This program (attempts to) compress data by performing several - non-trivial transformations on it. Unless you are 100% familiar - with *all* the algorithms contained herein, and with the - consequences of modifying them, you should NOT meddle with the - compression or decompression machinery. Incorrect changes can and - very likely *will* lead to disastrous loss of data. - - -DISCLAIMER: - - I TAKE NO RESPONSIBILITY FOR ANY LOSS OF DATA ARISING FROM THE - USE OF THIS PROGRAM, HOWSOEVER CAUSED. - - Every compression of a file implies an assumption that the - compressed file can be decompressed to reproduce the original. - Great efforts in design, coding and testing have been made to - ensure that this program works correctly. However, the complexity - of the algorithms, and, in particular, the presence of various - special cases in the code which occur with very low but non-zero - probability make it impossible to rule out the possibility of bugs - remaining in the program. DO NOT COMPRESS ANY DATA WITH THIS - PROGRAM UNLESS YOU ARE PREPARED TO ACCEPT THE POSSIBILITY, HOWEVER - SMALL, THAT THE DATA WILL NOT BE RECOVERABLE. - - That is not to say this program is inherently unreliable. Indeed, - I very much hope the opposite is true. bzip2 has been carefully - constructed and extensively tested. - - -PATENTS: - - To the best of my knowledge, bzip2 does not use any patented - algorithms. However, I do not have the resources to carry out - a patent search. Therefore I cannot give any guarantee of the - above statement. - -End of legalities. - - -WHAT'S NEW IN 0.9.0 (as compared to 0.1pl2) ? - - * Approx 10% faster compression, 30% faster decompression - * -t (test mode) is a lot quicker - * Can decompress concatenated compressed files - * Programming interface, so programs can directly read/write .bz2 files - * Less restrictive (BSD-style) licensing - * Flag handling more compatible with GNU gzip - * Much more documentation, i.e., a proper user manual - * Hopefully, improved portability (at least of the library) - -WHAT'S NEW IN 0.9.5 ? - - * Compression speed is much less sensitive to the input - data than in previous versions. Specifically, the very - slow performance caused by repetitive data is fixed. - * Many small improvements in file and flag handling. - * A Y2K statement. - -WHAT'S NEW IN 1.0.0 ? - - See the CHANGES file. - -WHAT'S NEW IN 1.0.2 ? - - See the CHANGES file. - -WHAT'S NEW IN 1.0.3 ? - - See the CHANGES file. - - -I hope you find bzip2 useful. Feel free to contact me at - jseward@bzip.org -if you have any suggestions or queries. Many people mailed me with -comments, suggestions and patches after the releases of bzip-0.15, -bzip-0.21, and bzip2 versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1 and -1.0.2, and the changes in bzip2 are largely a result of this feedback. -I thank you for your comments. - -At least for the time being, bzip2's "home" is (or can be reached via) -http://www.bzip.org - -Julian Seward -jseward@bzip.org - -Cambridge, UK. - -18 July 1996 (version 0.15) -25 August 1996 (version 0.21) - 7 August 1997 (bzip2, version 0.1) -29 August 1997 (bzip2, version 0.1pl2) -23 August 1998 (bzip2, version 0.9.0) - 8 June 1999 (bzip2, version 0.9.5) - 4 Sept 1999 (bzip2, version 0.9.5d) - 5 May 2000 (bzip2, version 1.0pre8) -30 December 2001 (bzip2, version 1.0.2pre1) -15 February 2005 (bzip2, version 1.0.3) - -############################################################################### -# Changes to the source of version 1.0.3 -############################################################################### -- Changed default installation to /usr/local -- Adjusted Makefile to separate testing from building, to allow chmem in - between -- Adjusted invocation of ar, as Minix ar does not support -q, even though the - documentation says it does diff --git a/commands/bzip2-1.0.3/build b/commands/bzip2-1.0.3/build deleted file mode 100755 index 03616c262..000000000 --- a/commands/bzip2-1.0.3/build +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -make clean -make all -if [ "$1" != build ] -then make install -fi diff --git a/commands/bzip2-1.0.3/bzdiff.1 b/commands/bzip2-1.0.3/bzdiff.1 deleted file mode 120000 index 7e8c80866..000000000 --- a/commands/bzip2-1.0.3/bzdiff.1 +++ /dev/null @@ -1 +0,0 @@ -../../man/man1/bzdiff.1 \ No newline at end of file diff --git a/commands/bzip2-1.0.3/bzgrep.1 b/commands/bzip2-1.0.3/bzgrep.1 deleted file mode 120000 index 7859ebbfa..000000000 --- a/commands/bzip2-1.0.3/bzgrep.1 +++ /dev/null @@ -1 +0,0 @@ -../../man/man1/bzgrep.1 \ No newline at end of file diff --git a/commands/bzip2-1.0.3/bzip2.1 b/commands/bzip2-1.0.3/bzip2.1 deleted file mode 120000 index 21f553196..000000000 --- a/commands/bzip2-1.0.3/bzip2.1 +++ /dev/null @@ -1 +0,0 @@ -../../man/man1/bzip2.1 \ No newline at end of file diff --git a/commands/bzip2-1.0.3/bzmore.1 b/commands/bzip2-1.0.3/bzmore.1 deleted file mode 120000 index adbf2b4de..000000000 --- a/commands/bzip2-1.0.3/bzmore.1 +++ /dev/null @@ -1 +0,0 @@ -../../man/man1/bzmore.1 \ No newline at end of file diff --git a/commands/bzip2-1.0.3/CHANGES b/commands/bzip2/CHANGES similarity index 100% rename from commands/bzip2-1.0.3/CHANGES rename to commands/bzip2/CHANGES diff --git a/commands/bzip2-1.0.3/LICENSE b/commands/bzip2/LICENSE similarity index 100% rename from commands/bzip2-1.0.3/LICENSE rename to commands/bzip2/LICENSE diff --git a/commands/bzip2/Makefile b/commands/bzip2/Makefile new file mode 100644 index 000000000..0768cee4c --- /dev/null +++ b/commands/bzip2/Makefile @@ -0,0 +1,14 @@ +.include + +PROG= bzip2 +DPADD+= ${LIBBZ2} +LDADD+= -lbz2 + +MLINKS+= bzip2.1 bunzip2.1\ + bzip2.1 bzcat.1\ + bzip2.1 bzip2recover.1 + +LINKS+= ${BINDIR}/bzip2 ${BINDIR}/bunzip2 +LINKS+= ${BINDIR}/bzip2 ${BINDIR}/bzcat + +.include diff --git a/commands/bzip2-1.0.3/Makefile-libbz2_so b/commands/bzip2/Makefile-libbz2_so similarity index 100% rename from commands/bzip2-1.0.3/Makefile-libbz2_so rename to commands/bzip2/Makefile-libbz2_so diff --git a/commands/bzip2-1.0.3/Makefile b/commands/bzip2/Makefile.orig similarity index 100% rename from commands/bzip2-1.0.3/Makefile rename to commands/bzip2/Makefile.orig diff --git a/commands/bzip2-1.0.3/README.ORIGINAL b/commands/bzip2/README similarity index 100% rename from commands/bzip2-1.0.3/README.ORIGINAL rename to commands/bzip2/README diff --git a/commands/bzip2-1.0.3/README.COMPILATION.PROBLEMS b/commands/bzip2/README.COMPILATION.PROBLEMS similarity index 100% rename from commands/bzip2-1.0.3/README.COMPILATION.PROBLEMS rename to commands/bzip2/README.COMPILATION.PROBLEMS diff --git a/commands/bzip2-1.0.3/README.XML.STUFF b/commands/bzip2/README.XML.STUFF similarity index 100% rename from commands/bzip2-1.0.3/README.XML.STUFF rename to commands/bzip2/README.XML.STUFF diff --git a/commands/bzip2-1.0.3/Y2K_INFO b/commands/bzip2/Y2K_INFO similarity index 100% rename from commands/bzip2-1.0.3/Y2K_INFO rename to commands/bzip2/Y2K_INFO diff --git a/commands/bzip2-1.0.3/blocksort.c b/commands/bzip2/blocksort.c similarity index 100% rename from commands/bzip2-1.0.3/blocksort.c rename to commands/bzip2/blocksort.c diff --git a/commands/bzip2-1.0.3/bz-common.xsl b/commands/bzip2/bz-common.xsl similarity index 100% rename from commands/bzip2-1.0.3/bz-common.xsl rename to commands/bzip2/bz-common.xsl diff --git a/commands/bzip2-1.0.3/bz-fo.xsl b/commands/bzip2/bz-fo.xsl similarity index 100% rename from commands/bzip2-1.0.3/bz-fo.xsl rename to commands/bzip2/bz-fo.xsl diff --git a/commands/bzip2-1.0.3/bz-html.xsl b/commands/bzip2/bz-html.xsl similarity index 100% rename from commands/bzip2-1.0.3/bz-html.xsl rename to commands/bzip2/bz-html.xsl diff --git a/commands/bzip2-1.0.3/bzdiff b/commands/bzip2/bzdiff similarity index 100% rename from commands/bzip2-1.0.3/bzdiff rename to commands/bzip2/bzdiff diff --git a/man/man1/bzdiff.1 b/commands/bzip2/bzdiff.1 similarity index 100% rename from man/man1/bzdiff.1 rename to commands/bzip2/bzdiff.1 diff --git a/commands/bzip2-1.0.3/bzgrep b/commands/bzip2/bzgrep similarity index 100% rename from commands/bzip2-1.0.3/bzgrep rename to commands/bzip2/bzgrep diff --git a/man/man1/bzgrep.1 b/commands/bzip2/bzgrep.1 similarity index 100% rename from man/man1/bzgrep.1 rename to commands/bzip2/bzgrep.1 diff --git a/commands/bzip2-1.0.3/bzip.css b/commands/bzip2/bzip.css similarity index 100% rename from commands/bzip2-1.0.3/bzip.css rename to commands/bzip2/bzip.css diff --git a/man/man1/bzip2.1 b/commands/bzip2/bzip2.1 similarity index 100% rename from man/man1/bzip2.1 rename to commands/bzip2/bzip2.1 diff --git a/commands/bzip2-1.0.3/bzip2.1.preformatted b/commands/bzip2/bzip2.1.preformatted similarity index 100% rename from commands/bzip2-1.0.3/bzip2.1.preformatted rename to commands/bzip2/bzip2.1.preformatted diff --git a/commands/bzip2-1.0.3/bzip2.c b/commands/bzip2/bzip2.c similarity index 100% rename from commands/bzip2-1.0.3/bzip2.c rename to commands/bzip2/bzip2.c diff --git a/commands/bzip2-1.0.3/bzip2.txt b/commands/bzip2/bzip2.txt similarity index 100% rename from commands/bzip2-1.0.3/bzip2.txt rename to commands/bzip2/bzip2.txt diff --git a/commands/bzip2-1.0.3/bzip2recover.c b/commands/bzip2/bzip2recover.c similarity index 100% rename from commands/bzip2-1.0.3/bzip2recover.c rename to commands/bzip2/bzip2recover.c diff --git a/commands/bzip2-1.0.3/bzlib.c b/commands/bzip2/bzlib.c similarity index 100% rename from commands/bzip2-1.0.3/bzlib.c rename to commands/bzip2/bzlib.c diff --git a/commands/bzip2-1.0.3/bzlib.h b/commands/bzip2/bzlib.h similarity index 100% rename from commands/bzip2-1.0.3/bzlib.h rename to commands/bzip2/bzlib.h diff --git a/commands/bzip2-1.0.3/bzlib_private.h b/commands/bzip2/bzlib_private.h similarity index 100% rename from commands/bzip2-1.0.3/bzlib_private.h rename to commands/bzip2/bzlib_private.h diff --git a/commands/bzip2-1.0.3/bzmore b/commands/bzip2/bzmore similarity index 100% rename from commands/bzip2-1.0.3/bzmore rename to commands/bzip2/bzmore diff --git a/man/man1/bzmore.1 b/commands/bzip2/bzmore.1 similarity index 100% rename from man/man1/bzmore.1 rename to commands/bzip2/bzmore.1 diff --git a/commands/bzip2-1.0.3/compress.c b/commands/bzip2/compress.c similarity index 100% rename from commands/bzip2-1.0.3/compress.c rename to commands/bzip2/compress.c diff --git a/commands/bzip2-1.0.3/crctable.c b/commands/bzip2/crctable.c similarity index 100% rename from commands/bzip2-1.0.3/crctable.c rename to commands/bzip2/crctable.c diff --git a/commands/bzip2-1.0.3/decompress.c b/commands/bzip2/decompress.c similarity index 100% rename from commands/bzip2-1.0.3/decompress.c rename to commands/bzip2/decompress.c diff --git a/commands/bzip2-1.0.3/dlltest.c b/commands/bzip2/dlltest.c similarity index 100% rename from commands/bzip2-1.0.3/dlltest.c rename to commands/bzip2/dlltest.c diff --git a/commands/bzip2-1.0.3/dlltest.dsp b/commands/bzip2/dlltest.dsp similarity index 100% rename from commands/bzip2-1.0.3/dlltest.dsp rename to commands/bzip2/dlltest.dsp diff --git a/commands/bzip2-1.0.3/entities.xml b/commands/bzip2/entities.xml similarity index 100% rename from commands/bzip2-1.0.3/entities.xml rename to commands/bzip2/entities.xml diff --git a/commands/bzip2-1.0.3/format.pl b/commands/bzip2/format.pl similarity index 100% rename from commands/bzip2-1.0.3/format.pl rename to commands/bzip2/format.pl diff --git a/commands/bzip2-1.0.3/huffman.c b/commands/bzip2/huffman.c similarity index 100% rename from commands/bzip2-1.0.3/huffman.c rename to commands/bzip2/huffman.c diff --git a/commands/bzip2-1.0.3/libbz2.def b/commands/bzip2/libbz2.def similarity index 100% rename from commands/bzip2-1.0.3/libbz2.def rename to commands/bzip2/libbz2.def diff --git a/commands/bzip2-1.0.3/libbz2.dsp b/commands/bzip2/libbz2.dsp similarity index 100% rename from commands/bzip2-1.0.3/libbz2.dsp rename to commands/bzip2/libbz2.dsp diff --git a/commands/bzip2-1.0.3/makefile.msc b/commands/bzip2/makefile.msc similarity index 100% rename from commands/bzip2-1.0.3/makefile.msc rename to commands/bzip2/makefile.msc diff --git a/commands/bzip2-1.0.3/mk251.c b/commands/bzip2/mk251.c similarity index 100% rename from commands/bzip2-1.0.3/mk251.c rename to commands/bzip2/mk251.c diff --git a/commands/bzip2-1.0.3/randtable.c b/commands/bzip2/randtable.c similarity index 100% rename from commands/bzip2-1.0.3/randtable.c rename to commands/bzip2/randtable.c diff --git a/commands/bzip2-1.0.3/sample1.bz2 b/commands/bzip2/sample1.bz2 similarity index 100% rename from commands/bzip2-1.0.3/sample1.bz2 rename to commands/bzip2/sample1.bz2 diff --git a/commands/bzip2-1.0.3/sample1.ref b/commands/bzip2/sample1.ref similarity index 100% rename from commands/bzip2-1.0.3/sample1.ref rename to commands/bzip2/sample1.ref diff --git a/commands/bzip2-1.0.3/sample2.bz2 b/commands/bzip2/sample2.bz2 similarity index 100% rename from commands/bzip2-1.0.3/sample2.bz2 rename to commands/bzip2/sample2.bz2 diff --git a/commands/bzip2-1.0.3/sample2.ref b/commands/bzip2/sample2.ref similarity index 100% rename from commands/bzip2-1.0.3/sample2.ref rename to commands/bzip2/sample2.ref diff --git a/commands/bzip2-1.0.3/sample3.bz2 b/commands/bzip2/sample3.bz2 similarity index 100% rename from commands/bzip2-1.0.3/sample3.bz2 rename to commands/bzip2/sample3.bz2 diff --git a/commands/bzip2-1.0.3/sample3.ref b/commands/bzip2/sample3.ref similarity index 100% rename from commands/bzip2-1.0.3/sample3.ref rename to commands/bzip2/sample3.ref diff --git a/commands/bzip2-1.0.3/spewG.c b/commands/bzip2/spewG.c similarity index 100% rename from commands/bzip2-1.0.3/spewG.c rename to commands/bzip2/spewG.c diff --git a/commands/bzip2-1.0.3/unzcrash.c b/commands/bzip2/unzcrash.c similarity index 100% rename from commands/bzip2-1.0.3/unzcrash.c rename to commands/bzip2/unzcrash.c diff --git a/commands/bzip2-1.0.3/words0 b/commands/bzip2/words0 similarity index 100% rename from commands/bzip2-1.0.3/words0 rename to commands/bzip2/words0 diff --git a/commands/bzip2-1.0.3/words1 b/commands/bzip2/words1 similarity index 100% rename from commands/bzip2-1.0.3/words1 rename to commands/bzip2/words1 diff --git a/commands/bzip2-1.0.3/words2 b/commands/bzip2/words2 similarity index 100% rename from commands/bzip2-1.0.3/words2 rename to commands/bzip2/words2 diff --git a/commands/bzip2-1.0.3/words3 b/commands/bzip2/words3 similarity index 100% rename from commands/bzip2-1.0.3/words3 rename to commands/bzip2/words3 diff --git a/commands/bzip2-1.0.3/xmlproc.sh b/commands/bzip2/xmlproc.sh similarity index 100% rename from commands/bzip2-1.0.3/xmlproc.sh rename to commands/bzip2/xmlproc.sh diff --git a/commands/bzip2recover/Makefile b/commands/bzip2recover/Makefile new file mode 100644 index 000000000..00837fdd8 --- /dev/null +++ b/commands/bzip2recover/Makefile @@ -0,0 +1,11 @@ +NOMAN= + +.include + +PROG= bzip2recover +CPPFLAGS+= -I ${BZ2DIR} + +BZ2DIR= ${MINIXSRCDIR}/commands/bzip2 +.PATH: ${BZ2DIR} + +.include diff --git a/commands/cal/Makefile b/commands/cal/Makefile new file mode 100644 index 000000000..69d99242f --- /dev/null +++ b/commands/cal/Makefile @@ -0,0 +1,4 @@ +PROG= cal +MAN= + +.include diff --git a/commands/simple/cal.c b/commands/cal/cal.c similarity index 100% rename from commands/simple/cal.c rename to commands/cal/cal.c diff --git a/commands/calendar/Makefile b/commands/calendar/Makefile new file mode 100644 index 000000000..0114fbc5c --- /dev/null +++ b/commands/calendar/Makefile @@ -0,0 +1,4 @@ +PROG= calendar +MAN= + +.include diff --git a/commands/simple/calendar.c b/commands/calendar/calendar.c similarity index 100% rename from commands/simple/calendar.c rename to commands/calendar/calendar.c diff --git a/commands/cat/Makefile b/commands/cat/Makefile new file mode 100644 index 000000000..e0e29c860 --- /dev/null +++ b/commands/cat/Makefile @@ -0,0 +1,5 @@ +PROG= cat +BINDIR= /bin +MAN= + +.include diff --git a/commands/simple/cat.c b/commands/cat/cat.c similarity index 100% rename from commands/simple/cat.c rename to commands/cat/cat.c diff --git a/commands/cawf/Makefile b/commands/cawf/Makefile index 02ef6bcdf..3eaa64048 100644 --- a/commands/cawf/Makefile +++ b/commands/cawf/Makefile @@ -33,75 +33,20 @@ # malloc() and its relatives (most do). # #DEFS = -DUNIX -DMALLOCH +DEFS= -DUNIX -DUSG -DSTDLIB +CPPFLAGS+= -i -f -wo ${DEFS} -CC = exec cc - -DEFS = -DUNIX -DUSG -DSTDLIB - -CFLAGS = -i -f -wo -O ${DEFS} - -HDR = ansi.h cawf.h cawflib.h proto.h regexp.h regmagic.h - -SRC = cawf.c device.c error.c expand.c expr.c getopt.c macsup.c nreq.c \ +PROGS= bsfilt cawf +SRCS.cawf= cawf.c device.c error.c expand.c expr.c getopt.c macsup.c nreq.c \ output.c pass2.c pass3.c regerror.c regexp.c store.c string.c +SRCS.bsfilt= bsfilt.c -OBJ = cawf.o device.o error.o expand.o expr.o getopt.o macsup.o nreq.o \ - output.o pass2.o pass3.o regerror.o regexp.o store.o string.o +LINKS+= ${BINDIR}/cawf ${BINDIR}/nroff +LINKS+= ${BINDIR}/bsfilt ${BINDIR}/colcrt +MAN.cawf= +MAN.bsfilt= -all: bsfilt cawf +FILESDIR= /usr/lib/cawf +FILES= common device.cf dumb.dev man.mac me.mac ms.mac mnx.mac -bsfilt: bsfilt.c - ${CC} ${CFLAGS} bsfilt.c -o $@ - install -S 4kw $@ - -cawf: ${OBJ} - ${CC} ${CFLAGS} ${OBJ} -o $@ - install -S 56k $@ - -clean: - rm -f *.o a.out core *errs bsfilt cawf - -${OBJ}: ${HDR} - -install: \ - /usr/bin/bsfilt /usr/bin/colcrt /usr/bin/cawf \ - /usr/bin/nroff /usr/lib/cawf /usr/lib/cawf/common \ - /usr/lib/cawf/device.cf /usr/lib/cawf/dumb.dev \ - /usr/lib/cawf/man.mac /usr/lib/cawf/me.mac \ - /usr/lib/cawf/ms.mac /usr/lib/cawf/mnx.mac - -/usr/bin/bsfilt: bsfilt - install -cs -o bin bsfilt $@ - -/usr/bin/colcrt: /usr/bin/bsfilt - install -l h /usr/bin/bsfilt $@ - -/usr/bin/cawf: cawf - install -cs -o bin cawf $@ - -/usr/bin/nroff: /usr/bin/cawf - install -l h /usr/bin/cawf $@ - -/usr/lib/cawf: - install -d -o bin /usr/lib/cawf - -/usr/lib/cawf/common: common - install -c -o bin common $@ - -/usr/lib/cawf/device.cf: device.cf - install -c -o bin device.cf $@ - -/usr/lib/cawf/dumb.dev: dumb.dev - install -c -o bin dumb.dev $@ - -/usr/lib/cawf/man.mac: man.mac - install -c -o bin man.mac $@ - -/usr/lib/cawf/me.mac: me.mac - install -c -o bin me.mac $@ - -/usr/lib/cawf/ms.mac: ms.mac - install -c -o bin ms.mac $@ - -/usr/lib/cawf/mnx.mac: mnx.mac - install -c -o bin mnx.mac $@ +.include diff --git a/commands/cawf/build b/commands/cawf/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/cawf/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/cawf/proto.h b/commands/cawf/proto.h index 29d2b4ade..a4bda9f23 100644 --- a/commands/cawf/proto.h +++ b/commands/cawf/proto.h @@ -97,7 +97,6 @@ _PROTOTYPE(int Findnum,(unsigned char *n, int v, int e)); _PROTOTYPE(int Findparms,(unsigned char *n)); _PROTOTYPE(int Findscale,(int n, double v, int e)); _PROTOTYPE(unsigned char *Findstr,(unsigned char *nm, unsigned char *s, int e)); -_PROTOTYPE(int getopt,(int argc, char **argv, char *opts)); _PROTOTYPE(int LenprtHF,(unsigned char *s, int p, int t)); _PROTOTYPE(int main,(int argc, char *argv[])); _PROTOTYPE(void Macro,(unsigned char *inp)); diff --git a/commands/cd/Makefile b/commands/cd/Makefile new file mode 100644 index 000000000..bac0f80b3 --- /dev/null +++ b/commands/cd/Makefile @@ -0,0 +1,18 @@ +SCRIPTS= cd.sh +BINDIR= /bin +MAN= + +LINKS+= ${BINDIR}/cd ${BINDIR}/[ +LINKS+= ${BINDIR}/cd ${BINDIR}/command +LINKS+= ${BINDIR}/cd ${BINDIR}/echo +LINKS+= ${BINDIR}/cd ${BINDIR}/expr +LINKS+= ${BINDIR}/cd ${BINDIR}/false +LINKS+= ${BINDIR}/cd ${BINDIR}/getopts +LINKS+= ${BINDIR}/cd ${BINDIR}/read +LINKS+= ${BINDIR}/cd ${BINDIR}/test +LINKS+= ${BINDIR}/cd ${BINDIR}/true +LINKS+= ${BINDIR}/cd ${BINDIR}/umask +LINKS+= ${BINDIR}/cd ${BINDIR}/wait + + +.include diff --git a/commands/scripts/cd.sh b/commands/cd/cd.sh old mode 100755 new mode 100644 similarity index 100% rename from commands/scripts/cd.sh rename to commands/cd/cd.sh diff --git a/commands/cdiff/Makefile b/commands/cdiff/Makefile new file mode 100644 index 000000000..902e00df6 --- /dev/null +++ b/commands/cdiff/Makefile @@ -0,0 +1,4 @@ +PROG= cdiff +MAN= + +.include diff --git a/commands/simple/cdiff.c b/commands/cdiff/cdiff.c similarity index 100% rename from commands/simple/cdiff.c rename to commands/cdiff/cdiff.c diff --git a/commands/cdprobe/Makefile b/commands/cdprobe/Makefile new file mode 100644 index 000000000..327dfe2e2 --- /dev/null +++ b/commands/cdprobe/Makefile @@ -0,0 +1,5 @@ +PROG= cdprobe +CPPFLAGS+= -I${MINIXSRCDIR}/servers +MAN= + +.include diff --git a/commands/simple/cdprobe.c b/commands/cdprobe/cdprobe.c similarity index 98% rename from commands/simple/cdprobe.c rename to commands/cdprobe/cdprobe.c index df7de4f87..d3785b82e 100644 --- a/commands/simple/cdprobe.c +++ b/commands/cdprobe/cdprobe.c @@ -22,7 +22,7 @@ #include #include -#include "../../servers/mfs/const.h" +#include "mfs/const.h" char pvd[CD_SECTOR]; diff --git a/commands/cgrep/Makefile b/commands/cgrep/Makefile new file mode 100644 index 000000000..8f6940d71 --- /dev/null +++ b/commands/cgrep/Makefile @@ -0,0 +1,4 @@ +PROG= cgrep +MAN= + +.include diff --git a/commands/simple/cgrep.c b/commands/cgrep/cgrep.c similarity index 100% rename from commands/simple/cgrep.c rename to commands/cgrep/cgrep.c diff --git a/commands/checkhier/Makefile b/commands/checkhier/Makefile new file mode 100644 index 000000000..6725dbb8e --- /dev/null +++ b/commands/checkhier/Makefile @@ -0,0 +1,4 @@ +SCRIPTS= checkhier.sh +MAN= + +.include diff --git a/commands/scripts/checkhier.sh b/commands/checkhier/checkhier.sh old mode 100755 new mode 100644 similarity index 100% rename from commands/scripts/checkhier.sh rename to commands/checkhier/checkhier.sh diff --git a/commands/chmem/Makefile b/commands/chmem/Makefile new file mode 100644 index 000000000..779500253 --- /dev/null +++ b/commands/chmem/Makefile @@ -0,0 +1,4 @@ +PROG= chmem +MAN= + +.include diff --git a/commands/simple/chmem.c b/commands/chmem/chmem.c similarity index 100% rename from commands/simple/chmem.c rename to commands/chmem/chmem.c diff --git a/commands/chmod/Makefile b/commands/chmod/Makefile new file mode 100644 index 000000000..15fccdc17 --- /dev/null +++ b/commands/chmod/Makefile @@ -0,0 +1,4 @@ +PROG= chmod +MAN= + +.include diff --git a/commands/simple/chmod.c b/commands/chmod/chmod.c similarity index 100% rename from commands/simple/chmod.c rename to commands/chmod/chmod.c diff --git a/commands/chown/Makefile b/commands/chown/Makefile new file mode 100644 index 000000000..807975d97 --- /dev/null +++ b/commands/chown/Makefile @@ -0,0 +1,6 @@ +PROG= chown +MAN= + +LINKS+= ${BINDIR}/chown ${BINDIR}/chgrp + +.include diff --git a/commands/simple/chown.c b/commands/chown/chown.c similarity index 100% rename from commands/simple/chown.c rename to commands/chown/chown.c diff --git a/commands/chroot/Makefile b/commands/chroot/Makefile new file mode 100644 index 000000000..eb3563642 --- /dev/null +++ b/commands/chroot/Makefile @@ -0,0 +1,5 @@ +PROG= chroot +BINDIR= /bin +MAN= + +.include diff --git a/commands/simple/chroot.c b/commands/chroot/chroot.c similarity index 100% rename from commands/simple/chroot.c rename to commands/chroot/chroot.c diff --git a/commands/ci/Makefile b/commands/ci/Makefile new file mode 100644 index 000000000..cbef9467c --- /dev/null +++ b/commands/ci/Makefile @@ -0,0 +1,4 @@ +PROG= ci +MAN= + +.include diff --git a/commands/simple/ci.c b/commands/ci/ci.c similarity index 100% rename from commands/simple/ci.c rename to commands/ci/ci.c diff --git a/commands/cksum/Makefile b/commands/cksum/Makefile new file mode 100644 index 000000000..e22eda4fa --- /dev/null +++ b/commands/cksum/Makefile @@ -0,0 +1,4 @@ +PROG= cksum +MAN= + +.include diff --git a/commands/simple/cksum.c b/commands/cksum/cksum.c similarity index 100% rename from commands/simple/cksum.c rename to commands/cksum/cksum.c diff --git a/commands/cleantmp/Makefile b/commands/cleantmp/Makefile new file mode 100644 index 000000000..5aab73026 --- /dev/null +++ b/commands/cleantmp/Makefile @@ -0,0 +1,4 @@ +PROG= cleantmp +MAN= + +.include diff --git a/commands/simple/cleantmp.c b/commands/cleantmp/cleantmp.c similarity index 100% rename from commands/simple/cleantmp.c rename to commands/cleantmp/cleantmp.c diff --git a/commands/clear/Makefile b/commands/clear/Makefile new file mode 100644 index 000000000..474335b2a --- /dev/null +++ b/commands/clear/Makefile @@ -0,0 +1,6 @@ +SCRIPTS= clear.sh +MAN= + +LINKS+= ${BINDIR}/clear ${BINDIR}/clr + +.include diff --git a/commands/scripts/clear.sh b/commands/clear/clear.sh old mode 100755 new mode 100644 similarity index 100% rename from commands/scripts/clear.sh rename to commands/clear/clear.sh diff --git a/commands/cmp/Makefile b/commands/cmp/Makefile new file mode 100644 index 000000000..68c1a5923 --- /dev/null +++ b/commands/cmp/Makefile @@ -0,0 +1,4 @@ +PROG= cmp +MAN= + +.include diff --git a/commands/simple/cmp.c b/commands/cmp/cmp.c similarity index 100% rename from commands/simple/cmp.c rename to commands/cmp/cmp.c diff --git a/commands/co/Makefile b/commands/co/Makefile new file mode 100644 index 000000000..f7605d7e1 --- /dev/null +++ b/commands/co/Makefile @@ -0,0 +1,4 @@ +PROG= co +MAN= + +.include diff --git a/commands/simple/co.c b/commands/co/co.c similarity index 100% rename from commands/simple/co.c rename to commands/co/co.c diff --git a/commands/comm/Makefile b/commands/comm/Makefile new file mode 100644 index 000000000..2766aad65 --- /dev/null +++ b/commands/comm/Makefile @@ -0,0 +1,4 @@ +PROG= comm +MAN= + +.include diff --git a/commands/simple/comm.c b/commands/comm/comm.c similarity index 100% rename from commands/simple/comm.c rename to commands/comm/comm.c diff --git a/commands/compress/Makefile b/commands/compress/Makefile new file mode 100644 index 000000000..4fd1d8cb9 --- /dev/null +++ b/commands/compress/Makefile @@ -0,0 +1,7 @@ +PROG= compress +MAN= + +LINKS+= ${BINDIR}/compress ${BINDIR}/uncompress +LINKS+= ${BINDIR}/compress ${BINDIR}/zcat + +.include diff --git a/commands/simple/compress.c b/commands/compress/compress.c similarity index 100% rename from commands/simple/compress.c rename to commands/compress/compress.c diff --git a/commands/cp/Makefile b/commands/cp/Makefile new file mode 100644 index 000000000..bd814b9b2 --- /dev/null +++ b/commands/cp/Makefile @@ -0,0 +1,11 @@ +PROG= cp +BINDIR= /bin +MAN= + +LINKS+= ${BINDIR}/cp ${BINDIR}/rm +LINKS+= ${BINDIR}/cp ${BINDIR}/mv +LINKS+= ${BINDIR}/cp ${BINDIR}/ln +LINKS+= ${BINDIR}/cp ${BINDIR}/clone +LINKS+= ${BINDIR}/cp ${BINDIR}/cpdir + +.include diff --git a/commands/simple/cp.c b/commands/cp/cp.c similarity index 100% rename from commands/simple/cp.c rename to commands/cp/cp.c diff --git a/commands/crc/Makefile b/commands/crc/Makefile new file mode 100644 index 000000000..112b107de --- /dev/null +++ b/commands/crc/Makefile @@ -0,0 +1,4 @@ +PROG= crc +MAN= + +.include diff --git a/commands/simple/crc.c b/commands/crc/crc.c similarity index 100% rename from commands/simple/crc.c rename to commands/crc/crc.c diff --git a/commands/cron/Makefile b/commands/cron/Makefile index 61cc3b52c..416f1f7fa 100644 --- a/commands/cron/Makefile +++ b/commands/cron/Makefile @@ -1,34 +1,7 @@ # Makefile for cron. -CFLAGS= -D_MINIX -D_POSIX_SOURCE -CC = exec cc -LDFLAGS= +PROG= cron +SRCS= cron.c tab.c misc.c +MAN= -all: cron crontab - -CRON_OBJ= cron.o tab.o misc.o -CRONTAB_OBJ= crontab.o tab.o misc.o - -cron: $(CRON_OBJ) - $(CC) $(LDFLAGS) -o $@ $(CRON_OBJ) - install -S 8kw $@ - -crontab: $(CRONTAB_OBJ) - $(CC) $(LDFLAGS) -o $@ $(CRONTAB_OBJ) - install -S 4kw $@ - -install: /usr/bin/cron /usr/bin/crontab - -/usr/bin/cron: cron - install -cs $? $@ - -/usr/bin/crontab: crontab - install -cs -o root -m 4755 $? $@ - -clean: - rm -f *.o cron crontab core a.out - -# Dependencies. -cron.o crontab.o: misc.h tab.h -tab.o: misc.h tab.h -misc.o: misc.h +.include diff --git a/commands/cron/build b/commands/cron/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/cron/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/crontab/Makefile b/commands/crontab/Makefile new file mode 100644 index 000000000..84929160b --- /dev/null +++ b/commands/crontab/Makefile @@ -0,0 +1,13 @@ +# Makefile for crontab. + +.include + +PROG= crontab +SRCS= crontab.c tab.c misc.c +CPPFLAGS+= -I${.CURDIR} -I${MINIXSRCDIR}/commands/cron +BINMODE= 4755 +MAN= + +.PATH: ${MINIXSRCDIR}/commands/cron + +.include diff --git a/commands/cron/crontab.c b/commands/crontab/crontab.c similarity index 100% rename from commands/cron/crontab.c rename to commands/crontab/crontab.c diff --git a/commands/cut/Makefile b/commands/cut/Makefile new file mode 100644 index 000000000..d2d459608 --- /dev/null +++ b/commands/cut/Makefile @@ -0,0 +1,4 @@ +PROG= cut +MAN= + +.include diff --git a/commands/simple/cut.c b/commands/cut/cut.c similarity index 100% rename from commands/simple/cut.c rename to commands/cut/cut.c diff --git a/commands/datasizes/Makefile b/commands/datasizes/Makefile new file mode 100644 index 000000000..2aed57a6c --- /dev/null +++ b/commands/datasizes/Makefile @@ -0,0 +1,4 @@ +SCRIPTS= datasizes.sh +MAN= + +.include diff --git a/commands/scripts/datasizes.sh b/commands/datasizes/datasizes.sh similarity index 100% rename from commands/scripts/datasizes.sh rename to commands/datasizes/datasizes.sh diff --git a/commands/date/Makefile b/commands/date/Makefile new file mode 100644 index 000000000..3fad6a011 --- /dev/null +++ b/commands/date/Makefile @@ -0,0 +1,11 @@ +.include + +PROG= date +SRCS= date.c logwtmp.c +TZDIR= /usr/share/zoneinfo +CPPFLAGS+= -DHAVE_ADJTIME=0 -DTZDIR=\"$(TZDIR)\" +BINDIR= /bin + +.PATH: ${MINIXSRCDIR}/lib/libc/stdtime + +.include diff --git a/commands/dd/Makefile b/commands/dd/Makefile new file mode 100644 index 000000000..7a740bb3a --- /dev/null +++ b/commands/dd/Makefile @@ -0,0 +1,4 @@ +PROG= dd +MAN= + +.include diff --git a/commands/simple/dd.c b/commands/dd/dd.c similarity index 100% rename from commands/simple/dd.c rename to commands/dd/dd.c diff --git a/commands/de/Makefile b/commands/de/Makefile index 386d5e177..369c5da8f 100644 --- a/commands/de/Makefile +++ b/commands/de/Makefile @@ -1,22 +1,9 @@ # Makefile for de -CC = exec cc -CFLAGS = -O -D_MINIX -D_POSIX_SOURCE -D_POSIX_1_SOURCE=2 +PROG= de +SRCS= de.c de_stdin.c de_stdout.c de_diskio.c de_recover.c +CPPFLAGS+= -I${MINIXSRCDIR}/servers +CPPFLAGS+= -D_POSIX_1_SOURCE=2 +MAN= -all: de - -OBJS = de.o de_stdin.o de_stdout.o de_diskio.o de_recover.o - -de: $(OBJS) - $(CC) -i $(OBJS) -o de - install -S 4kw de - -install: /usr/bin/de - -/usr/bin/de: de - install -cs -o bin de $@ - -$(OBJS): de.h - -clean: - rm -f *.bak *.o de +.include diff --git a/commands/de/build b/commands/de/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/de/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/de/de.c b/commands/de/de.c index a8d93e379..3c6f98abe 100644 --- a/commands/de/de.c +++ b/commands/de/de.c @@ -27,9 +27,9 @@ #include #include -#include "../../servers/mfs/const.h" -#include "../../servers/mfs/type.h" -#include "../../servers/mfs/inode.h" +#include "mfs/const.h" +#include "mfs/type.h" +#include "mfs/inode.h" #include "de.h" diff --git a/commands/de/de_diskio.c b/commands/de/de_diskio.c index 2151c359f..79cc143b9 100644 --- a/commands/de/de_diskio.c +++ b/commands/de/de_diskio.c @@ -18,10 +18,10 @@ #include #include -#include "../../servers/mfs/const.h" -#include "../../servers/mfs/type.h" -#include "../../servers/mfs/super.h" -#include "../../servers/mfs/inode.h" +#include "mfs/const.h" +#include "mfs/type.h" +#include "mfs/super.h" +#include "mfs/inode.h" #include #include "de.h" diff --git a/commands/de/de_recover.c b/commands/de/de_recover.c index a26b4cc88..37437dda8 100644 --- a/commands/de/de_recover.c +++ b/commands/de/de_recover.c @@ -23,9 +23,9 @@ #include #include -#include "../../servers/mfs/const.h" -#include "../../servers/mfs/type.h" -#include "../../servers/mfs/inode.h" +#include "mfs/const.h" +#include "mfs/type.h" +#include "mfs/inode.h" #include #include "de.h" diff --git a/commands/de/de_stdin.c b/commands/de/de_stdin.c index 5f440d8d6..325427527 100644 --- a/commands/de/de_stdin.c +++ b/commands/de/de_stdin.c @@ -17,8 +17,8 @@ #include #include -#include "../../servers/mfs/const.h" -#include "../../servers/mfs/inode.h" +#include "mfs/const.h" +#include "mfs/inode.h" #include "de.h" diff --git a/commands/de/de_stdout.c b/commands/de/de_stdout.c index e3f86fd04..725d4c703 100644 --- a/commands/de/de_stdout.c +++ b/commands/de/de_stdout.c @@ -25,9 +25,9 @@ #include #include -#include "../../servers/mfs/const.h" -#include "../../servers/mfs/type.h" -#include "../../servers/mfs/inode.h" +#include "mfs/const.h" +#include "mfs/type.h" +#include "mfs/inode.h" #include #include "de.h" diff --git a/commands/decomp16/Makefile b/commands/decomp16/Makefile new file mode 100644 index 000000000..ac2fa3e48 --- /dev/null +++ b/commands/decomp16/Makefile @@ -0,0 +1,4 @@ +PROG= decomp16 +MAN= + +.include diff --git a/commands/simple/decomp16.c b/commands/decomp16/decomp16.c similarity index 100% rename from commands/simple/decomp16.c rename to commands/decomp16/decomp16.c diff --git a/commands/dev2name/Makefile b/commands/dev2name/Makefile new file mode 100644 index 000000000..5a7a0af02 --- /dev/null +++ b/commands/dev2name/Makefile @@ -0,0 +1,5 @@ +PROG= dev2name +BINDIR= /bin +MAN= + +.include diff --git a/commands/simple/dev2name.c b/commands/dev2name/dev2name.c similarity index 100% rename from commands/simple/dev2name.c rename to commands/dev2name/dev2name.c diff --git a/commands/devsize/Makefile b/commands/devsize/Makefile new file mode 100644 index 000000000..76348ce81 --- /dev/null +++ b/commands/devsize/Makefile @@ -0,0 +1,4 @@ +PROG= devsize +MAN= + +.include diff --git a/commands/simple/devsize.c b/commands/devsize/devsize.c similarity index 100% rename from commands/simple/devsize.c rename to commands/devsize/devsize.c diff --git a/commands/df/Makefile b/commands/df/Makefile new file mode 100644 index 000000000..a76e1bdfe --- /dev/null +++ b/commands/df/Makefile @@ -0,0 +1,6 @@ +PROG= df +CPPFLAGS+= -I${MINIXSRCDIR} +BINMODE= 4755 +MAN= + +.include diff --git a/commands/simple/df.c b/commands/df/df.c similarity index 100% rename from commands/simple/df.c rename to commands/df/df.c diff --git a/commands/dhcpd/Makefile b/commands/dhcpd/Makefile index 70921fdc5..b3e4689d0 100644 --- a/commands/dhcpd/Makefile +++ b/commands/dhcpd/Makefile @@ -1,25 +1,7 @@ # Makefile for dhcpd. -CFLAGS = $(OPT) -D_MINIX -LDFLAGS = -CC = exec cc +PROG= dhcpd +SRCS= dhcpd.c tags.c devices.c ether.c +MAN= -all: dhcpd - -OBJ= dhcpd.o tags.o devices.o ether.o - -dhcpd: $(OBJ) - $(CC) $(LDFLAGS) -o $@ $(OBJ) - install -S 12kw $@ - -install: /usr/bin/dhcpd - -/usr/bin/dhcpd: dhcpd - install -c $? $@ - -clean: - rm -f *.o dhcpd core a.out - -# Dependencies. -$(OBJ): dhcpd.h -dhcpd.o ether.o: arp.h +.include diff --git a/commands/dhcpd/build b/commands/dhcpd/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/dhcpd/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/dhrystone/Makefile b/commands/dhrystone/Makefile new file mode 100644 index 000000000..767d3a0bd --- /dev/null +++ b/commands/dhrystone/Makefile @@ -0,0 +1,4 @@ +PROG= dhrystone +MAN= + +.include diff --git a/commands/simple/dhrystone.c b/commands/dhrystone/dhrystone.c similarity index 100% rename from commands/simple/dhrystone.c rename to commands/dhrystone/dhrystone.c diff --git a/commands/diff/Makefile b/commands/diff/Makefile new file mode 100644 index 000000000..5d974e093 --- /dev/null +++ b/commands/diff/Makefile @@ -0,0 +1,4 @@ +PROG= diff +MAN= + +.include diff --git a/commands/simple/diff.c b/commands/diff/diff.c similarity index 100% rename from commands/simple/diff.c rename to commands/diff/diff.c diff --git a/commands/dirname/Makefile b/commands/dirname/Makefile new file mode 100644 index 000000000..73c59d5cf --- /dev/null +++ b/commands/dirname/Makefile @@ -0,0 +1,4 @@ +PROG= dirname +MAN= + +.include diff --git a/commands/simple/dirname.c b/commands/dirname/dirname.c similarity index 100% rename from commands/simple/dirname.c rename to commands/dirname/dirname.c diff --git a/commands/dis88/Makefile b/commands/dis88/Makefile index 9f863341a..15a699b20 100644 --- a/commands/dis88/Makefile +++ b/commands/dis88/Makefile @@ -24,27 +24,9 @@ # the initialization data in the lookup tables. It should not # be necessary to alter the formats of the tables. -CFLAGS =-O -wo -OBJ = disrel.o dismain.o distabs.o dishand.o disfp.o -CC=exec cc +PROG= dis88 +SRCS= disrel.c dismain.c distabs.c dishand.c disfp.c +CPPFLAGS+= -wo +MAN= -all: dis88 - -dis88: $(OBJ) - cc -i -o dis88 $(OBJ) - install -S 5kw dis88 - -install: /usr/bin/dis88 - -/usr/bin/dis88: dis88 - install -cs -o bin dis88 $@ - -disrel.o: disrel.c -dismain.o: dismain.c dis.h -distabs.o: distabs.c dis.h -dishand.o: dishand.c dis.h -disfp.o: disfp.c dis.h - - -clean: - rm -f *.bak *.o core dis88 +.include diff --git a/commands/dis88/build b/commands/dis88/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/dis88/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/dosread/Makefile b/commands/dosread/Makefile new file mode 100644 index 000000000..394a5df69 --- /dev/null +++ b/commands/dosread/Makefile @@ -0,0 +1,7 @@ +PROG= dosread +MAN= + +LINKS+= ${BINDIR}/dosread ${BINDIR}/doswrite +LINKS+= ${BINDIR}/dosread ${BINDIR}/dosdir + +.include diff --git a/commands/ibm/dosread.c b/commands/dosread/dosread.c similarity index 100% rename from commands/ibm/dosread.c rename to commands/dosread/dosread.c diff --git a/commands/du/Makefile b/commands/du/Makefile new file mode 100644 index 000000000..a37f2ea57 --- /dev/null +++ b/commands/du/Makefile @@ -0,0 +1,4 @@ +PROG= du +MAN= + +.include diff --git a/commands/simple/du.c b/commands/du/du.c similarity index 100% rename from commands/simple/du.c rename to commands/du/du.c diff --git a/commands/dumpcore/Makefile b/commands/dumpcore/Makefile new file mode 100644 index 000000000..de8682fc7 --- /dev/null +++ b/commands/dumpcore/Makefile @@ -0,0 +1,5 @@ +PROG= dumpcore +CPPFLAGS+= -I${MINIXSRCDIR} +MAN= + +.include diff --git a/commands/simple/dumpcore.c b/commands/dumpcore/dumpcore.c similarity index 99% rename from commands/simple/dumpcore.c rename to commands/dumpcore/dumpcore.c index fe2078940..a33f13250 100644 --- a/commands/simple/dumpcore.c +++ b/commands/dumpcore/dumpcore.c @@ -16,7 +16,7 @@ #include #include -#include "../../kernel/proc.h" +#include "kernel/proc.h" #define CLICK_WORDS (CLICK_SIZE / sizeof(unsigned long)) diff --git a/commands/easypack/Makefile b/commands/easypack/Makefile new file mode 100644 index 000000000..8eac3e57b --- /dev/null +++ b/commands/easypack/Makefile @@ -0,0 +1,4 @@ +SCRIPTS= easypack.sh +MAN= + +.include diff --git a/commands/scripts/easypack.sh b/commands/easypack/easypack.sh similarity index 100% rename from commands/scripts/easypack.sh rename to commands/easypack/easypack.sh diff --git a/commands/ed/Makefile b/commands/ed/Makefile new file mode 100644 index 000000000..4a5327378 --- /dev/null +++ b/commands/ed/Makefile @@ -0,0 +1,4 @@ +PROG= ed +MAN= + +.include diff --git a/commands/simple/ed.c b/commands/ed/ed.c similarity index 100% rename from commands/simple/ed.c rename to commands/ed/ed.c diff --git a/commands/eject/Makefile b/commands/eject/Makefile new file mode 100644 index 000000000..6550a8fbc --- /dev/null +++ b/commands/eject/Makefile @@ -0,0 +1,4 @@ +PROG= eject +MAN= + +.include diff --git a/commands/simple/eject.c b/commands/eject/eject.c similarity index 100% rename from commands/simple/eject.c rename to commands/eject/eject.c diff --git a/commands/elle/Makefile b/commands/elle/Makefile index d8221eac9..e7bd6c6e4 100644 --- a/commands/elle/Makefile +++ b/commands/elle/Makefile @@ -1,24 +1,14 @@ # Makefile for elle -CC = exec cc -CFLAGS = -O -DIGN_JOB_CONTROL -D_POSIX_SOURCE -wa -LDFLAGS= -i - -all: elle ellec - -OBJ = eemain.o eecmds.o eesite.o eevini.o eedisp.o eeterm.o eeerr.o \ - eeques.o eebuff.o eefile.o eefed.o eeedit.o eebit.o eef1.o \ - eef2.o eefd.o eehelp.o eekmac.o eef3.o eesrch.o eequer.o \ - eefill.o eediag.o sbstr.o sbm.o sberr.o sbbcpy.o - -# It probably isn't necessary to make all this stuff all the time, but it -# is fairly easy and makes the whole process simpler. If this is not done, -# the dependencies are very complicated because some of the .c and .h files -# are made dynamically. -elle: ellec $(OBJ) $(FUN_OFILES) elle.h eesite.h -# $(CC) $(CFLAGS) -c defprf.c # depends on the new *.h files - $(CC) $(LDFLAGS) -o $@ $(OBJ) - install -S 64k $@ +PROGS= ellec elle +SRCS.elle= eemain.c eecmds.c eesite.c eevini.c eedisp.c eeterm.c eeerr.c \ + eeques.c eebuff.c eefile.c eefed.c eeedit.c eebit.c eef1.c \ + eef2.c eefd.c eehelp.c eekmac.c eef3.c eesrch.c eequer.c \ + eefill.c eediag.c sbstr.c sbm.c sberr.c +SRCS.ellec= ellec.c +CPPFLAGS+= -DIGN_JOB_CONTROL -wa +MAN.elle= +MAN.ellec= defprf.c: deffun.e cat deffun.e defprf.e | ellec -Pconf > defprf.c @@ -32,26 +22,4 @@ eefidx.h: deffun.e # Don't flush these files if interrupted, dammit! .PRECIOUS: ellec deffun.e defprf.e -# The following files must be recompiled if eefidx.h is changed -eecmds.o eebuff.o eeerr.o eehelp.o eejust.o eemain.o eeques.o eef1.o: eefidx.h - -# ELLE profile compiler. -# Although eefdef.h and defprf.c are included by ELLEC, they -# are not listed as dependencies in order to avoid loops (see -# their target entries). That is OK because their information is not -# used when generating the makecf files; it only furnishes default -# values needed when an ELLE user compiles a user profile. -ellec: ellec.c - $(CC) $(LDFLAGS) $(CFLAGS) -o $@ ellec.c - install -S 8kw $@ - -install: /usr/bin/elle /usr/bin/ellec - -/usr/bin/elle: elle - install -cs -o bin elle $@ - -/usr/bin/ellec: ellec - install -cs -o bin ellec $@ - -clean: - rm -f *.o *.bak core elle ellec +.include diff --git a/commands/elle/build b/commands/elle/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/elle/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/elvis/Makefile b/commands/elvis/Makefile index 602d327c8..cf3cd0fb5 100644 --- a/commands/elvis/Makefile +++ b/commands/elvis/Makefile @@ -9,90 +9,31 @@ # PROGS the list of all programs # SORT if the "tags" file must be sorted, then SORT=-DSORT -CC = exec cc PROGS= elvis ctags ref elvrec fmt elvprsv - -#---- These settings are recommended for Minix-PC ---- -EXTRA= tinytcap.o tinyprnt.o -CFLAGS= -O -w -D_POSIX_SOURCE -D_MINIX -DCRUNCH \ +CPPFLAGS+= -w -DCRUNCH \ -DNO_MKEXRC -DNO_CURSORSHAPE -DNO_CHARATTR -DNO_SHOWMODE \ -DNO_MODELINE -DNO_OPTCOLS -DNO_DIGRAPH -DNO_EXTENSIONS \ -DNO_ERRLIST -DNO_FKEY -DNO_VISIBLE -DNO_COLOR -DNO_POPUP -LDFLAGS=-i - -#---- These settings are recommended for Minix-ST ---- -#EXTRA= -#CFLAGS= ########################################################################### ### The rest of this Makefile contains no user-serviceable parts ### ########################################################################### -OBJ=blk.o cmd1.o cmd2.o ctype.o curses.o cut.o ex.o input.o \ - main.o misc.o modify.o move1.o move2.o move3.o move4.o move5.o \ - opts.o recycle.o redraw.o regexp.o regsub.o system.o tio.o tmp.o \ - unix.o vars.o vcmd.o vi.o +SRCS.elvis= blk.c cmd1.c cmd2.c ctype.c curses.c cut.c ex.c input.c \ + main.c misc.c modify.c move1.c move2.c move3.c move4.c move5.c \ + opts.c recycle.c redraw.c regexp.c regsub.c system.c tio.c tmp.c \ + unix.c vars.c vcmd.c vi.c -all: $(PROGS) +BINDIR= /usr/bin +.if !exists(${BINDIR}/vi) +LINKS+= ${BINDIR}/elvis ${BINDIR}/vi +.endif -elvis: $(OBJ) - $(CC) $(LDFLAGS) -o elvis $(OBJ) - install -S 18kw elvis +MAN.elvis= +MAN.ctags= +MAN.ref= +MAN.elvrec= +MAN.fmt= +MAN.elvprsv= -ctags: ctags.c - $(CC) $(CFLAGS) $(SORT) $(LDFLAGS) -o ctags ctags.c - install -S 4kw $@ - -ref: ref.c - $(CC) $(CFLAGS) $(LDFLAGS) -o ref ref.c - install -S 4kw $@ - -elvrec: elvrec.c - $(CC) $(CFLAGS) $(LDFLAGS) -o elvrec elvrec.c - install -S 4kw $@ - -fmt: fmt.c - $(CC) $(CFLAGS) $(LDFLAGS) -o fmt fmt.c - install -S 4kw $@ - -elvprsv: elvprsv.c - $(CC) $(CFLAGS) $(LDFLAGS) -o elvprsv elvprsv.c ctype.o - install -S 4kw $@ - -install: /usr/bin/elvis \ - /bin/elvis \ - /usr/bin/vi \ - /usr/bin/ctags /usr/bin/ref /usr/bin/fmt \ - /usr/bin/elvrec /usr/bin/elvprsv - -/usr/bin/elvis: elvis - install -cs -o bin elvis $@ - -/bin/elvis: elvis - install -cs -o bin elvis $@ - -/usr/bin/vi: /usr/bin/elvis - if [ ! -x $@ ]; \ - then install -l h $? $@ ; \ - fi - -/usr/bin/ctags: ctags - install -cs -o bin ctags $@ - -/usr/bin/ref: ref - install -cs -o bin ref $@ - -/usr/bin/fmt: fmt - install -cs -o bin fmt $@ - -/usr/bin/elvrec: elvrec - install -cs -o root -m 4755 elvrec $@ - -/usr/bin/elvprsv: elvprsv - install -cs -o root -m 4755 elvprsv $@ - -# Dependencies -$(OBJ): vi.h curses.h config.h regexp.h ctype.h - -clean: - rm -f *.o ctags ref elvrec fmt elvprsv elvis +.include diff --git a/commands/elvis/build b/commands/elvis/build deleted file mode 100755 index 4fc1aeec5..000000000 --- a/commands/elvis/build +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -make && make install diff --git a/commands/elvis/ctags.c b/commands/elvis/ctags.c index b7424e5b7..700138a58 100644 --- a/commands/elvis/ctags.c +++ b/commands/elvis/ctags.c @@ -341,7 +341,7 @@ cpp_ungetc(ch) /* -------------------------------------------------------------------------- */ /* This is the lexical analyser. It gets characters from the preprocessor, * and gives tokens to the parser. Some special codes are... - * (deleted) /*...* / (comments) + * (deleted) / *...* / (comments) * (deleted) //...\n (comments) * (deleted) (* (parens used in complex declaration) * (deleted) [...] (array subscript, when ... contains no ]) diff --git a/commands/elvis/ref.c b/commands/elvis/ref.c index 8c6b57aa0..a0aaf4e86 100644 --- a/commands/elvis/ref.c +++ b/commands/elvis/ref.c @@ -153,7 +153,7 @@ int getline(buf, limit, fp) * To display the tag, it attempts to output any introductory comment, the * tag line itself, and any arguments. Arguments are assumed to immediately * follow the tag line, and start with whitespace. Comments are assumed to - * start with lines that begin with "/*", "//", "(*", or "--", and end at the + * start with lines that begin with "/ *", "//", "(*", or "--", and end at the * tag line or at a blank line. */ int lookup(dir, entry) diff --git a/commands/env/Makefile b/commands/env/Makefile new file mode 100644 index 000000000..242767dad --- /dev/null +++ b/commands/env/Makefile @@ -0,0 +1,6 @@ +PROG= env +MAN= + +LINKS+= ${BINDIR}/env ${BINDIR}/printenv + +.include diff --git a/commands/simple/env.c b/commands/env/env.c similarity index 100% rename from commands/simple/env.c rename to commands/env/env.c diff --git a/commands/expand/Makefile b/commands/expand/Makefile new file mode 100644 index 000000000..dead4bd66 --- /dev/null +++ b/commands/expand/Makefile @@ -0,0 +1,4 @@ +PROG= expand +MAN= + +.include diff --git a/commands/simple/expand.c b/commands/expand/expand.c similarity index 100% rename from commands/simple/expand.c rename to commands/expand/expand.c diff --git a/commands/factor/Makefile b/commands/factor/Makefile new file mode 100644 index 000000000..e991858aa --- /dev/null +++ b/commands/factor/Makefile @@ -0,0 +1,4 @@ +PROG= factor +MAN= + +.include diff --git a/commands/simple/factor.c b/commands/factor/factor.c similarity index 100% rename from commands/simple/factor.c rename to commands/factor/factor.c diff --git a/commands/fdisk/Makefile b/commands/fdisk/Makefile new file mode 100644 index 000000000..c2a8f4238 --- /dev/null +++ b/commands/fdisk/Makefile @@ -0,0 +1,4 @@ +PROG= fdisk +MAN= + +.include diff --git a/commands/ibm/fdisk.c b/commands/fdisk/fdisk.c similarity index 100% rename from commands/ibm/fdisk.c rename to commands/fdisk/fdisk.c diff --git a/commands/fgrep/Makefile b/commands/fgrep/Makefile new file mode 100644 index 000000000..104d00cb6 --- /dev/null +++ b/commands/fgrep/Makefile @@ -0,0 +1,4 @@ +PROG= fgrep +MAN= + +.include diff --git a/commands/simple/fgrep.c b/commands/fgrep/fgrep.c similarity index 100% rename from commands/simple/fgrep.c rename to commands/fgrep/fgrep.c diff --git a/commands/file/Makefile b/commands/file/Makefile new file mode 100644 index 000000000..47011dd6b --- /dev/null +++ b/commands/file/Makefile @@ -0,0 +1,4 @@ +PROG= file +MAN= + +.include diff --git a/commands/simple/file.c b/commands/file/file.c similarity index 100% rename from commands/simple/file.c rename to commands/file/file.c diff --git a/commands/find/Makefile b/commands/find/Makefile new file mode 100644 index 000000000..c03849c0d --- /dev/null +++ b/commands/find/Makefile @@ -0,0 +1,4 @@ +PROG= find +MAN= + +.include diff --git a/commands/simple/find.c b/commands/find/find.c similarity index 100% rename from commands/simple/find.c rename to commands/find/find.c diff --git a/commands/finger/Makefile b/commands/finger/Makefile new file mode 100644 index 000000000..7dc1a3299 --- /dev/null +++ b/commands/finger/Makefile @@ -0,0 +1,4 @@ +PROG= finger +MAN= + +.include diff --git a/commands/simple/finger.c b/commands/finger/finger.c similarity index 100% rename from commands/simple/finger.c rename to commands/finger/finger.c diff --git a/commands/fingerd/Makefile b/commands/fingerd/Makefile new file mode 100644 index 000000000..88574f861 --- /dev/null +++ b/commands/fingerd/Makefile @@ -0,0 +1,5 @@ +PROG= in.fingerd +SRCS= fingerd.c +MAN= + +.include diff --git a/commands/simple/in.fingerd.c b/commands/fingerd/fingerd.c similarity index 100% rename from commands/simple/in.fingerd.c rename to commands/fingerd/fingerd.c diff --git a/commands/fix/Makefile b/commands/fix/Makefile new file mode 100644 index 000000000..68a20c279 --- /dev/null +++ b/commands/fix/Makefile @@ -0,0 +1,4 @@ +PROG= fix +MAN= + +.include diff --git a/commands/simple/fix.c b/commands/fix/fix.c similarity index 100% rename from commands/simple/fix.c rename to commands/fix/fix.c diff --git a/commands/flex-2.5.4/.descr b/commands/flex-2.5.4/.descr deleted file mode 100644 index 3463a4173..000000000 --- a/commands/flex-2.5.4/.descr +++ /dev/null @@ -1 +0,0 @@ -Lexical scanner generator diff --git a/commands/flex-2.5.4/INSTALL b/commands/flex-2.5.4/INSTALL deleted file mode 100644 index 6e7ed85d2..000000000 --- a/commands/flex-2.5.4/INSTALL +++ /dev/null @@ -1,117 +0,0 @@ -This is a generic INSTALL file for utilities distributions. -If this package does not come with, e.g., installable documentation or -data files, please ignore the references to them below. - -To compile this package: - -1. Configure the package for your system. In the directory that this -file is in, type `./configure'. If you're using `csh' on an old -version of System V, you might need to type `sh configure' instead to -prevent `csh' from trying to execute `configure' itself. - -The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation, and -creates the Makefile(s) (one in each subdirectory of the source -directory). In some packages it creates a C header file containing -system-dependent definitions. It also creates a file `config.status' -that you can run in the future to recreate the current configuration. - -Running `configure' takes a minute or two. While it is running, it -prints some messages that tell what it is doing. If you don't want to -see the messages, run `configure' with its standard output redirected -to `/dev/null'; for example, `./configure >/dev/null'. - -To compile the package in a different directory from the one -containing the source code, you must use a version of `make' that -supports the VPATH variable, such as GNU `make'. `cd' to the directory -where you want the object files and executables to go and run -`configure'. `configure' automatically checks for the source code in -the directory that `configure' is in and in `..'. If for some reason -`configure' is not in the source code directory that you are -configuring, then it will report that it can't find the source code. -In that case, run `configure' with the option `--srcdir=DIR', where -DIR is the directory that contains the source code. - -By default, `make install' will install the package's files in -/usr/local/bin, /usr/local/lib, /usr/local/man, etc. You can specify -an installation prefix other than /usr/local by giving `configure' the -option `--prefix=PATH'. Alternately, you can do so by giving a value -for the `prefix' variable when you run `make', e.g., - make prefix=/usr/gnu - -You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If -you give `configure' the option `--exec-prefix=PATH' or set the -`make' variable `exec_prefix' to PATH, the package will use PATH as -the prefix for installing programs and libraries. Data files and -documentation will still use the regular prefix. Normally, all files -are installed using the regular prefix. - -Another `configure' option is useful mainly in `Makefile' rules for -updating `config.status' and `Makefile'. The `--no-create' option -figures out the configuration for your system and records it in -`config.status', without actually configuring the package (creating -`Makefile's and perhaps a configuration header file). Later, you can -run `./config.status' to actually configure the package. You can also -give `config.status' the `--recheck' option, which makes it re-run -`configure' with the same arguments you used before. This option is -useful if you change `configure'. - -Some packages pay attention to `--with-PACKAGE' options to `configure', -where PACKAGE is something like `gnu-libc' or `x' (for X windows). -The README should mention any --with- options that the package recognizes. - -`configure' ignores any other arguments that you give it. - -If your system requires unusual options for compilation or linking -that `configure' doesn't know about, you can give `configure' initial -values for some variables by setting them in the environment. In -Bourne-compatible shells, you can do that on the command line like -this: - CC='gcc -traditional' DEFS=-D_POSIX_SOURCE ./configure - -The `make' variables that you might want to override with environment -variables when running `configure' are: - -(For these variables, any value given in the environment overrides the -value that `configure' would choose:) -CC C compiler program. - Default is `cc', or `gcc' if `gcc' is in your PATH. -INSTALL Program to use to install files. - Default is `install' if you have it, `cp' otherwise. - -(For these variables, any value given in the environment is added to -the value that `configure' chooses:) -DEFS Configuration options, in the form `-Dfoo -Dbar ...' - Do not use this variable in packages that create a - configuration header file. -LIBS Libraries to link with, in the form `-lfoo -lbar ...' - -If you need to do unusual things to compile the package, we encourage -you to figure out how `configure' could check whether to do them, and -mail diffs or instructions to the address given in the README so we -can include them in the next release. - -2. Type `make' to compile the package. If you want, you can override -the `make' variables CFLAGS and LDFLAGS like this: - - make CFLAGS=-O2 LDFLAGS=-s - -3. If the package comes with self-tests and you want to run them, -type `make check'. If you're not sure whether there are any, try it; -if `make' responds with something like - make: *** No way to make target `check'. Stop. -then the package does not come with self-tests. - -4. Type `make install' to install programs, data files, and -documentation. - -5. You can remove the program binaries and object files from the -source directory by typing `make clean'. To also remove the -Makefile(s), the header file containing system-dependent definitions -(if the package uses one), and `config.status' (all the files that -`configure' created), type `make distclean'. - -The file `configure.in' is used as a template to create `configure' by -a program called `autoconf'. You will only need it if you want to -regenerate `configure' using a newer version of `autoconf'. diff --git a/commands/flex-2.5.4/MISC/Amiga/README.amiga b/commands/flex-2.5.4/MISC/Amiga/README.amiga deleted file mode 100644 index 0efdb9383..000000000 --- a/commands/flex-2.5.4/MISC/Amiga/README.amiga +++ /dev/null @@ -1,72 +0,0 @@ - -This file, ./MISC/Amiga/README.amiga, describes the necessary steps to get -the FLEX 2.5.1 program up and running on the Commodore AMIGA with the -help of SAS/C++ 6.51 and SMake 6.50. Also it describes the contents of the -subdirectory ./MISC/Amiga, where `.' denotes the root directory of the -standard installation of FLEX 2.5.1. - - -FILES ADDED FOR INSTALLING FLEX 2.5.1 ON THE AMIGA - -The standard distribution of FLEX 2.5.1 is assumed to be installed on -your AMIGA computer. `Installed' means that all source files from the -original archive are present in a root directory (denoted by `.' in what -follows) and, if appropriate, one or more subdirectories, on your machine. - -The original source files are totally left untouched, the necessary changes -are applied in the form of `change files'. For installing FLEX 2.5.1 on -the AMIGA, several additional files come with this patch. - - -----rw-d 2 738 Apr 3 11:49 config.h - -----rw-d 1 169 Apr 3 11:33 libmain.ch - -----rw-d 1 159 Apr 3 11:33 libyywrap.ch - -----rw-d 1 167 Apr 3 11:33 parse.ych - -----rw-d 6 2840 Apr 3 11:34 README.amiga - -----rw-d 11 5503 Apr 3 11:45 smakefile - Dirs:0 Files:6 Blocks:22 Bytes:9576 - - -HOW TO INSTALL FLEX 2.5.1 ON THE AMIGA - -Copy all files from ./MISC/Amiga to the root directory of the FLEX 2.5.1 -distribution and edit `SMakefile' as it instructs you. There shouldn't be -too many changes necessary. Then say "make bootflex". This creates a -preliminary version of FLEX 2.5.1 without using itself. - -WARNING: Don't say "make flex" yet. Any pre-2.5 version of FLEX will fail -on the file `scan.l' due to some new features only present in FLEX 2.5. - -Then say "make flex". At least once the FLEX program created in the first -step will be used. To make sure that everything is alright, finally say -"make check". If you change the code, you should also say "make bigcheck" -for some more thorough testing. - -When you are satisfied with the results, say "make install". This will -copy the `flex' binary, the `libfl.lib' file, and the `FlexLexer.h' header -to the paths specified in the `SMakefile'. - -Finally, you should say "make clean" to remove all intermediate files from -the root directory. "make veryclean" also removes `flex' and `scan.c'. - - -TROUBLE SHOOTING - -FLEX 2.5.1 was ported to the AMIGA and tested with the following setup: - - AMIGA 2000 - GVP G-Force 030/50/50/8 - SAS/C++ 6.51 - SED 2.05 - BISON 1.22 - WMERGE from the CWEB distribution - -Should you encounter problems with this AMIGA patch for FLEX 2.5.1 or -should you have ideas for further improvements, like using GnuMake instead -of SMake, contact the author of this contribution - -Andreas Scherer -Roland-Stra{\ss}e 16 -52070 Aachen -Germany - - (Internet) diff --git a/commands/flex-2.5.4/MISC/Amiga/SMakefile b/commands/flex-2.5.4/MISC/Amiga/SMakefile deleted file mode 100644 index fc6c1ef60..000000000 --- a/commands/flex-2.5.4/MISC/Amiga/SMakefile +++ /dev/null @@ -1,195 +0,0 @@ -# @(#) $Header$ (LBL) - -# If your version of "make" does not define $(MAKE), comment in the -# definition of "MAKE" below. (You only need to do this if you intend -# to do "make bigcheck" or "make dist".) -MAKE = smake - -# Possible values for DEFS: -# -# For flex to always generate 8-bit scanners, add "-DDEFAULT_CSIZE=256" -# to DEFS. -# -# For Vax/VMS, add "-DVMS" to DEFS. -# -# For MS-DOS, add "-DMS_DOS" to DEFS. See the directory MISC/MSDOS for -# additional info. - -CFLAGS = data=far ignore=85 noicons stackextend optimize -DEFS = define=YYBISON=1 define=YY_NEVER_INTERACTIVE=1 -LDFLAGS = noicons -LIBS = - -# Installation targeting. Files will be installed under the tree -# rooted at prefix. flex will be installed in bindir, libfl.lib in -# libdir, FlexLexer.h will be installed in includedir, and the manual -# pages will be installed in mandir with extension manext. -# -# Raw, unformatted troff source will be installed if INSTALLMAN=man, -# nroff preformatted versions will be installed if INSTALLMAN=cat. - -prefix = Programmer:other # Change this for your AMIGA system. -exec_prefix = $(prefix) -bindir = $(exec_prefix)/bin -libdir = $(exec_prefix)/lib -includedir = $(prefix)/include -manext = 1 -mandir = $(prefix)/man/man$(manext) - -# You can define this to be "lex" if you want to replace lex at your site. -FLEX = flex - -INSTALLMAN = man - -SHELL = -srcdir = . -VPATH = - -LN_S = -YACC = bison -y -SED = sed -CC = sc -WMERGE = wmerge # from the CWEB distribution -AR = oml -RANLIB = -INSTALL = copy clone -INSTALL_DATA = $(INSTALL) -INSTALL_PROGRAM = $(INSTALL) - -# You normally do not need to modify anything below this point. -# ------------------------------------------------------------ - -CPPFLAGS = idir=. idir=$(srcdir) $(DEFS) - -.c.o: - $(CC) $(CPPFLAGS) $(CFLAGS) $< - -HEADERS = flexdef.h version.h - -SOURCES = ccl.c dfa.c ecs.c gen.c main.c misc.c nfa.c parse.y \ - scan.l skel.c sym.c tblcmp.c yylex.c -OBJECTS = ccl.o dfa.o ecs.o gen.o main.o misc.o nfa.o parse.o \ - skel.o sym.o tblcmp.o yylex.o \ - $(libdir)/alloca.o $(libdir)/xmalloc.o - -LIBSRCS = libmain.c libyywrap.c -LIBOBJS = ansilibmain.o ansilibyywrap.o - -LINTSRCS = ccl.c dfa.c ecs.c gen.c main.c misc.c nfa.c parse.c \ - scan.c skel.c sym.c tblcmp.c yylex.c - -DISTFILES = README NEWS COPYING INSTALL FlexLexer.h \ - configure.in conf.in Makefile.in mkskel.sh skel.c flex.skl \ - $(HEADERS) $(SOURCES) $(LIBSRCS) MISC \ - flex.1 scan.c install.sh mkinstalldirs configure - -DIST_NAME = flex - -# which "flex" to use to generate scan.c from scan.l -FLEX_EXEC = ./$(FLEX) -FLEX_FLAGS = -t $(PERF_REPORT) -COMPRESSION = -PERF_REPORT = -p - -FLEXLIB = libfl.lib - -all: $(FLEX) - -$(FLEX): $(OBJECTS) $(FLEXLIB) scan.o - $(CC) $(CFLAGS) link to $(FLEX) $(LDFLAGS) $(OBJECTS) scan.o $(FLEXLIB) $(LIBS) - -bootflex: $(OBJECTS) $(FLEXLIB) initscan.o - $(CC) $(CFLAGS) link to $(FLEX) $(LDFLAGS) $(OBJECTS) initscan.o $(FLEXLIB) $(LIBS) - -parse.c: ansiparse.y - $(YACC) -d ansiparse.y - $(SED) "/extern char.*malloc/d" parse.tmp - copy parse.tmp parse.c - copy y.tab.h parse.h - @delete y.tab.c y.tab.h parse.tmp -ansiparse.y: $(srcdir)/parse.y parse.ych - $(WMERGE) $(srcdir)/parse.y parse.ych ansiparse.y - -parse.h: parse.c - -scan.c: scan.l - $(FLEX_EXEC) $(FLEX_FLAGS) $(COMPRESSION) $(srcdir)/scan.l >scan.tmp - $(SED) s,\"$(srcdir)/scan.l\",\"scan.l\", scan.c - @delete scan.tmp - -scan.o: scan.c parse.h flexdef.h config.h -initscan.o: initscan.c parse.h flexdef.h config.h -yylex.o: yylex.c parse.h flexdef.h config.h - -skel.c: flex.skl mkskel.sh - $(SHELL) $(srcdir)/mkskel.sh $(srcdir)/flex.skl >skel.c - -main.o: main.c flexdef.h config.h version.h -ccl.o: ccl.c flexdef.h config.h -dfa.o: dfa.c flexdef.h config.h -ecs.o: ecs.c flexdef.h config.h -gen.o: gen.c flexdef.h config.h -misc.o: misc.c flexdef.h config.h -nfa.o: nfa.c flexdef.h config.h -parse.o: parse.c flexdef.h config.h -skel.o: skel.c flexdef.h config.h -sym.o: sym.c flexdef.h config.h -tblcmp.o: tblcmp.c flexdef.h config.h - -alloca.o: alloca.c - $(CC) $(CPPFLAGS) $(CFLAGS) define=xmalloc=yy_flex_xmalloc alloca.c - -alloca.c: $(srcdir)/MISC/alloca.c - @delete alloca.c - copy $(srcdir)/MISC/alloca.c . - -test: check -check: flex - $(FLEX_EXEC) $(FLEX_FLAGS) $(COMPRESSION) $(srcdir)/scan.l > temp_a - $(SED) s,"$(srcdir)/scan.l","scan.l", < temp_a > temp_b - -diff scan.c temp_b -l10000 -w - @delete temp_? - @echo "Check successful, using COMPRESSION='$(COMPRESSION)'" - -bigcheck: - delete scan.c - $(MAKE) COMPRESSION=-C check - delete scan.c - $(MAKE) COMPRESSION=-Ce check - delete scan.c - $(MAKE) COMPRESSION=-Cm check - delete scan.c - $(MAKE) COMPRESSION=-Cfea check - delete scan.c - $(MAKE) COMPRESSION=-CFer check - delete scan.c - $(MAKE) COMPRESSION=-l PERF_REPORT= check - delete scan.c - $(MAKE) - @echo "All checks successful" - -$(FLEXLIB): $(LIBOBJS) - $(AR) $(FLEXLIB) R $(LIBOBJS) - -$(FLEX).man: flex.1 # SMAKE can't `cd', sorry. And, I don't have nroff. -# cd $(srcdir), nroff -man flex.1 >$(FLEX).man - -install: $(FLEX) $(FLEXLIB) - $(INSTALL_PROGRAM) $(FLEX) $(bindir)/$(FLEX) -# @delete $(bindir)/$(FLEX)++ - $(INSTALL_DATA) $(FLEXLIB) $(libdir)/libfl.lib - $(INSTALL_DATA) $(srcdir)/FlexLexer.h $(includedir)/FlexLexer.h - -ansilibmain.o: ansilibmain.c -ansilibmain.c: libmain.c libmain.ch - $(WMERGE) libmain.c libmain.ch ansilibmain.c -ansilibyywrap.o: ansilibyywrap.c -ansilibyywrap.c: libyywrap.c libyywrap.ch - $(WMERGE) libyywrap.c libyywrap.ch ansilibyywrap.c - -clean: - -delete parse.(c|h) ansi\#? \#?.(bak|o|lnk) \ - alloca.c lex.yy.(c|cc) $(FLEXLIB) - -veryclean: clean - -delete $(FLEX) scan.c diff --git a/commands/flex-2.5.4/MISC/Amiga/config.h b/commands/flex-2.5.4/MISC/Amiga/config.h deleted file mode 100644 index 8eb279fcf..000000000 --- a/commands/flex-2.5.4/MISC/Amiga/config.h +++ /dev/null @@ -1,25 +0,0 @@ -/* $Header$ */ - -/* Define to empty if the keyword does not work. */ -#undef const - -/* Define to `unsigned' if doesn't define. */ -#undef size_t - -/* Define if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define if you have the header file. */ -#undef HAVE_MALLOC_H - -/* Define if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define if you have and it should be used (not on Ultrix). */ -#undef HAVE_ALLOCA_H - -/* Define if platform-specific command line handling is necessary. */ -#undef NEED_ARGV_FIXUP diff --git a/commands/flex-2.5.4/MISC/Amiga/libmain.ch b/commands/flex-2.5.4/MISC/Amiga/libmain.ch deleted file mode 100644 index e0f5b4090..000000000 --- a/commands/flex-2.5.4/MISC/Amiga/libmain.ch +++ /dev/null @@ -1,8 +0,0 @@ -Changes for LIBMAIN.C 2.4.7 by Andreas Scherer, January 19, 1995. -Modified for LIBMAIN.C 2.5.1, April 3, 1995. - -@x l.5 -extern int yylex(); -@y -extern int yylex(void); -@z diff --git a/commands/flex-2.5.4/MISC/Amiga/libyywrap.ch b/commands/flex-2.5.4/MISC/Amiga/libyywrap.ch deleted file mode 100644 index b2d6a3fe3..000000000 --- a/commands/flex-2.5.4/MISC/Amiga/libyywrap.ch +++ /dev/null @@ -1,8 +0,0 @@ -Changes for LIBYYWRAP.C 2.4.7 by Andreas Scherer, January 19, 1995. -Modified for LIBYYWRAP.C 2.5.1, April 3, 1995. - -@x l.5 -int yywrap() -@y -int yywrap(void) -@z diff --git a/commands/flex-2.5.4/MISC/Amiga/parse.ych b/commands/flex-2.5.4/MISC/Amiga/parse.ych deleted file mode 100644 index 5671a5b1e..000000000 --- a/commands/flex-2.5.4/MISC/Amiga/parse.ych +++ /dev/null @@ -1,8 +0,0 @@ -Changes for PARSE.Y 2.4.7 by Andreas Scherer, January 20, 1995. -Modified for PARSE.Y 2.5.1, April 3, 1995. - -@x l.60 -char *alloca (); -@y -char *alloca(unsigned int); -@z diff --git a/commands/flex-2.5.4/MISC/Atari/Atari.patches b/commands/flex-2.5.4/MISC/Atari/Atari.patches deleted file mode 100644 index 69e9ceb45..000000000 --- a/commands/flex-2.5.4/MISC/Atari/Atari.patches +++ /dev/null @@ -1,911 +0,0 @@ -(Message inbox:32) -Date: Mon, 03 Jul 89 21:15:32 CET -From: V61%DHDURZ1.BITNET@lbl.gov -Subject: Flex, bug fix, improvments, patches for Minix & TOS -To: vern@lbl-csam.arpa - -At first I have to thank you for your wonderful program. I had ported the -old version to OS9,TOS (Atari ST) and Minix and the new version 2.1 Beta -to Minix and TOS. - -While porting and using flex I detected a bug and made some improvements. -I have included a shared, compressed and uuencoded file contaning all cdiffs -and additional files (Sorry, but I'm on EBCDIC-Bitnet) and a short discussion -of the changes. Even some of the TOS specific changes might be of general -interest ! - -I posted these cdiffs to the minix discussion group, but I think it's up -to you to post them to the unix-sources group. If you plan to post even -the TOS compiler specific patches please contact me because there might be -further compiler (P.D.) additions. If you have an interest I could also -port the new version to OS9 -- this is a little bit more difficult, because -OS9 uses CR as end of line character (the EOL char. is coded into the -initscan.c tables,...). It is necessary to change all occurences of '\n' to -macros and variables and it's useful to add a new -n options (see commented -line in main.c) - - - -The changes: (1.7.89 RAL) - - - Bug fix: The original flex didn't like trailing spaces in exclusive start - condition lists ! If you add an trailing space to line 68 in scan.l - - "%x SECT2 SECT2PROLOG SECT3 CODEBLOCK PICKUPDEF SC CARETISBOL NUM QUOTE " - - you get a misleading error message: - - "Syntax error at line 69: bad start condition list" - - This bug can either be fixed in parse.y or in scan.l . I have chosen the - last because there the fix is minimal: Just change the rule (line 128) - - "\n" to "{OPTWS}\n" - - - Enhancements: - - new option "-?" that provides some help information about the other - flags (main.c) - - new option "-aTMPPATH" that allows a redefinition of the standard - path for the temporary file (this might be rather large >200k if - F,f options are selected). (main.c, flexdef.h (l.376)) - - hexdump of illegal characters -- this proved to be a useful debugging - tool especialy if invisible control characters occur which weren't - covered by the rules. (scan.l fprintf statement line 129,...) - - - Patches due to TOS - - General: TOS uses CR,LF as end of line char., Flex wants only a single - LF as EOL char. Therefore all I/O must be translated using f* calls. - This is done everywhere besides the YY_INPUT macro (flex.skel (scan.c), - line 31) that uses a low level 'read'. This should be definitly changed - to fread, so that all I/O calls occur on the same level. - - the short action_file_name has been "flexXXXXXX.tmp", but that's too - much for TOS,MSDOS ! I changed it to "flexXXXX.tmp" in main.c (patch - covered by the -a option additions) - - some compilers don't like external names that are ambiguous within - the first 8 characters. I defined macros that change all these long - external names to names that are unique within the first 8 characters. - Just define SHORT_EXTERNAL_NAMES to use this feature (flexdef.h) - - some statement changes that some compiler don't like: - typedef *xxx[] -> typedef **xxx (flexdef.h.,l.308) - "/*" -> '/','*' within a comment in (scan.l, l.209) - - changed short "lexyy.c" to "lex_yy.c" what's more similar to the unix - "lex.yy.c" (main.c). - - a few further really compiler dependent changes provided with - #ifdef ATARI && LATTICE res. TURBO braces. - - - Additional TOS only files - - Makefile.tos: Common makefile for all TOS compilers. If you add further - ones please email me the new makefile. - - flex.lnk: Lattice - GST linker argument extension file - - flex.tlk: Turbo linker argument extension file - - -Additional remarks: - -I didn't add a new initscan.c (= flex -ist scan.l). The current one is good -enough for a first compilation. With this first version of flex you can -rebuild your own scan.c and the final flex version ! - -Minix ST : - - I had to "chmem =70000 cv" (>50000) to get flex linked - - 'memset' (PC 1.3, EFTH40,...) is necessary - - chmem =90000 flex may be sufficient - -Minix PC : - It should be possible to port Flex to Minix PC. The current sizes of flex - are: - Minix ST (ACK) Lattice (TOS) Turbo (TOS) - - size 75300 83305 57957 - compilation time 22' 15' 3'40" - flex -is scan.l 1'49" 43" 30" - - The Minix ST size includes the bad generated code using only a subset of - the 68000 commands, long addresses only and a huge relocation table. - Therefore the PC size will be <64 k ! More serious is the fact that I had - to chmem =90000 flex to get scan.l converted to scan.c . But I never saw - a more complex lex source than scan.l -- so it should be possible to - reduce some array sizes without limitation for all day usage. - - No one volunteered yet for a Minix PC port -- but if someone will try it - I would provide him with a new scan.c and some hints. - -TOS: - Don't forget to adapt the flexskel path within flexdef.h ! - - -Bitnet: V61@DHDURZ1 Ronald Lamprecht -UUCP: ...!unido!DHDURZ1.bitnet!V61 Theoretische Physik -ARPAnet: V61%DHDURZ1.BITNET@CUNYVM.CUNY.EDU (Heidelberg, West Germany) -(Message inbox:36) -Date: Wed, 05 Jul 89 21:16:07 CET -From: V61%DHDURZ1.BITNET@csa2.lbl.gov -Subject: Re: What is TOS -To: vern@lbl-csam.arpa - -TOS is the name of the Atari ST operating system that is very similar -to MSDOS (Both use CR,LF as end of line character). Therefore I have -been astonished that no EOL convertion porblems occur within MSDOS. - -I have been aware of the double buffering when changing read to fread and I -accept your argument of a possible slow down. But if you integrate the other -Atari - TOS changes, please insert a - #ifdef ATARI - fread .... - #else - read .... - #endif -in flex.skel . - -Bitnet: V61@DHDURZ1 Ronald Lamprecht -UUCP: ...!unido!DHDURZ1.bitnet!V61 Theoretische Physik -ARPAnet: V61%DHDURZ1.BITNET@CUNYVM.CUNY.EDU (Heidelberg, West Germany) - - - - -echo x - Makefile_cdiff -sed '/^X/s///' > Makefile_cdiff << '/' -X*** Src_2.1/Makefile Thu Jun 28 00:06:42 1989 -X--- Makefile Thu Jul 3 02:12:48 1989 -X*************** -X*** 5,10 **** -X--- 5,11 ---- -X # Porting considerations: -X # -X # For System V Unix machines, add -DSYS_V to CFLAGS. -X+ # For Minix (ST), add -DSYS_V to CFLAGS -X # For Vax/VMS, add -DSYS_V to CFLAGS. -X # For MS-DOS, add "-DMS_DOS -DSYS_V" to CFLAGS. Create \tmp if not present. -X # You will also want to rename flex.skel to something with a three -X*************** -X*** 21,28 **** -X SKELETON_DIR = /usr/local/lib -X SKELETON_FILE = flex.skel -X SKELFLAGS = -DDEFAULT_SKELETON_FILE=\"$(SKELETON_DIR)/$(SKELETON_FILE)\" -X! CFLAGS = -O -X! LDFLAGS = -s -X -X FLEX_FLAGS = -X FLEX = ./flex -X--- 22,29 ---- -X SKELETON_DIR = /usr/local/lib -X SKELETON_FILE = flex.skel -X SKELFLAGS = -DDEFAULT_SKELETON_FILE=\"$(SKELETON_DIR)/$(SKELETON_FILE)\" -X! CFLAGS = -O -DSYS_V -X! LDFLAGS = -X -X FLEX_FLAGS = -X FLEX = ./flex -X*************** -X*** 57,63 **** -X yylex.c -X -X flex : $(FLEXOBJS) -X! $(CC) $(CFLAGS) -o flex $(LDFLAGS) $(FLEXOBJS) -X -X first_flex: -X cp initscan.c scan.c -X--- 58,65 ---- -X yylex.c -X -X flex : $(FLEXOBJS) -X! $(CC) $(CFLAGS) -o flex $(FLEXOBJS) $(LDFLAGS) -X! chmem =150000 flex -X -X first_flex: -X cp initscan.c scan.c -/ -echo x - flex.skel_cdif -sed '/^X/s///' > flex.skel_cdif << '/' -X*** Src_2.1/flex.skel Thu Jun 28 00:19:20 1989 -X--- flex.skel Thu Jul 2 22:18:31 1989 -X*************** -X*** 28,34 **** -X * is returned in "result". -X */ -X #define YY_INPUT(buf,result,max_size) \ -X! if ( (result = read( fileno(yyin), buf, max_size )) < 0 ) \ -X YY_FATAL_ERROR( "read() in flex scanner failed" ); -X #define YY_NULL 0 -X #define yyterminate() return ( YY_NULL ) -X--- 28,34 ---- -X * is returned in "result". -X */ -X #define YY_INPUT(buf,result,max_size) \ -X! if ( (result = fread( buf,1, max_size, yyin )) < 0 ) \ -X YY_FATAL_ERROR( "read() in flex scanner failed" ); -X #define YY_NULL 0 -X #define yyterminate() return ( YY_NULL ) -/ -echo x - flexdef.h_cdif -sed '/^X/s///' > flexdef.h_cdif << '/' -X*** Src_2.1/flexdef.h Thu Jun 28 00:43:27 1989 -X--- flexdef.h Thu Jul 3 02:45:50 1989 -X*************** -X*** 26,31 **** -X--- 26,40 ---- -X -X /* @(#) $Header$ (LBL) */ -X -X+ #ifdef ATARI -X+ #define SYS_V -X+ #define abs(x) ((x) < 0 ? -(x) : (x)) -X+ #define SHORT_FILE_NAMES -X+ #ifdef TURBO -X+ #define SHORT_EXTERNAL_NAMES -X+ #endif -X+ #endif -X+ -X #ifndef FILE -X #include -X #endif -X*************** -X*** 41,47 **** -X #endif -X -X #ifndef VMS -X! char *memset(); -X #else -X /* memset is needed for old versions of the VMS C runtime library */ -X #define memset(s, c, n) \ -X--- 50,58 ---- -X #endif -X -X #ifndef VMS -X! #ifndef ATARI && TURBO -X! char *memset(); -X! #endif -X #else -X /* memset is needed for old versions of the VMS C runtime library */ -X #define memset(s, c, n) \ -X*************** -X*** 81,91 **** -X--- 92,129 ---- -X #define true 1 -X #define false 0 -X -X+ #ifdef ATARI -X+ #define DEFAULT_SKELETON_FILE "D:\\include\\flexskel" -X+ #endif -X+ -X -X #ifndef DEFAULT_SKELETON_FILE -X #define DEFAULT_SKELETON_FILE "flex.skel" -X #endif -X -X+ #ifdef SHORT_EXTERNAL_NAMES -X+ /* avoid long external names that are ambiguous within the first 8 characters */ -X+ #define current_mns c__mns -X+ #define current_max_rules c__max_rules -X+ #define current_max_state_type c__max_state_type -X+ #define current_max_scs c__max_scs -X+ #define current_max_dfa_size c__max__size -X+ #define current_max_xpairs c__max_xpairs -X+ #define current_max_template_xpairs c__max_template_xpairs -X+ #define current_max_dfas c__max_dfas -X+ #define current_maxccls c__maxccles -X+ #define current_max_ccl_tbl_size c__max_ccl_tbl_size -X+ #define indent_puts ind_puts -X+ #define indent_put2s ind_put2s -X+ #define gen_next_compressed_state gen_n_comressed_state -X+ #define gen_next_match gen_n_match -X+ #define gen_next_state gen_n_state -X+ #define variable_trailing_context_rules var_tr_context_rules -X+ #define variable_trailing_rule var_tr_rule -X+ #define backtrack_report backtr_report -X+ #define backtrack_file backtr_file -X+ #endif -X+ -X /* special chk[] values marking the slots taking by end-of-buffer and action -X * numbers -X */ -X*************** -X*** 305,311 **** -X int int_val; -X } ; -X -X! typedef struct hash_entry *hash_table[]; -X -X #define NAME_TABLE_HASH_SIZE 101 -X #define START_COND_HASH_SIZE 101 -X--- 343,349 ---- -X int int_val; -X } ; -X -X! typedef struct hash_entry **hash_table; -X -X #define NAME_TABLE_HASH_SIZE 101 -X #define START_COND_HASH_SIZE 101 -X*************** -X*** 372,378 **** -X extern int datapos, dataline, linenum; -X extern FILE *skelfile, *yyin, *temp_action_file, *backtrack_file; -X extern char *infilename; -X! extern char action_file_name[]; -X -X -X /* variables for stack of states having only one out-transition: -X--- 410,416 ---- -X extern int datapos, dataline, linenum; -X extern FILE *skelfile, *yyin, *temp_action_file, *backtrack_file; -X extern char *infilename; -X! extern char *action_file_name; -X -X -X /* variables for stack of states having only one out-transition: -/ -echo x - main.c_cdiff -sed '/^X/s///' > main.c_cdiff << '/' -X*** Src_2.1/main.c Thu Jun 28 00:30:39 1989 -X--- main.c Thu Jul 3 02:27:47 1989 -X*************** -X*** 81,96 **** -X FILE *temp_action_file; -X FILE *backtrack_file; -X int end_of_buffer_state; -X! #ifndef SHORT_FILE_NAMES -X! char action_file_name[] = "/tmp/flexXXXXXX"; -X! #else -X! char action_file_name[] = "flexXXXXXX.tmp"; -X! #endif -X! -X #ifndef SHORT_FILE_NAMES -X static char outfile[] = "lex.yy.c"; -X #else -X! static char outfile[] = "lexyy.c"; -X #endif -X static int outfile_created = 0; -X -X--- 81,91 ---- -X FILE *temp_action_file; -X FILE *backtrack_file; -X int end_of_buffer_state; -X! char *action_file_name; -X #ifndef SHORT_FILE_NAMES -X static char outfile[] = "lex.yy.c"; -X #else -X! static char outfile[] = "lex_yy.c"; -X #endif -X static int outfile_created = 0; -X -X*************** -X*** 328,333 **** -X--- 323,329 ---- -X { -X int i, sawcmpflag, use_stdout; -X char *arg, *skelname = NULL, *flex_gettime(), clower(), *mktemp(); -X+ char *tmp_action =(char *)0, *malloc(); -X -X printstats = syntaxerror = trace = spprdflt = interactive = caseins = false; -X backtrack_report = performance_report = ddebug = fulltbl = fullspd = false; -X*************** -X*** 349,354 **** -X--- 345,355 ---- -X for ( i = 1; arg[i] != '\0'; ++i ) -X switch ( arg[i] ) -X { -X+ case 'a': -X+ if ( i != 1 ) -X+ flexerror( "-a flag must be given separately" ); -X+ tmp_action = &arg[i+1]; -X+ goto get_next_arg; -X case 'b': -X backtrack_report = true; -X break; -X*************** -X*** 445,452 **** -X printstats = true; -X break; -X -X! default: -X! lerrif( "unknown flag %c", (int) arg[i] ); -X break; -X } -X -X--- 446,458 ---- -X printstats = true; -X break; -X -X! case '?': -X! flexinfo(0); -X! break; -X! -X! default: -X! fprintf(stderr,"flex : unknown flag %c\n", (int) arg[i] ); -X! flexinfo(1); -X break; -X } -X -X*************** -X*** 454,459 **** -X--- 460,493 ---- -X ; -X } -X -X+ -X+ /* if you change the default tmp file names don't forget to change the -X+ initialization for i, too ! -X+ -X+ */ -X+ #ifndef SHORT_FILE_NAMES -X+ i = 10; -X+ if (!tmp_action) i += 5; -X+ #else -X+ i = 12; -X+ #endif -X+ if (tmp_action) -X+ i += strlen(tmp_action) + 1; -X+ if((action_file_name = malloc(i+1)) == (char *)0) -X+ flexerror("No memory for action_file_name"); -X+ *action_file_name = (char) NULL; -X+ if (tmp_action) -X+ strcat(action_file_name,tmp_action); -X+ #ifndef SHORT_FILE_NAMES -X+ else -X+ strcat(action_file_name,"/tmp"); -X+ strcat(action_file_name,"/flexXXXXXX"); -X+ #else -X+ if (tmp_action) -X+ strcat(action_file_name,"/"); -X+ strcat(action_file_name,"flexXXXX.tmp"); -X+ #endif -X+ -X if ( (fulltbl || fullspd) && usemecs ) -X flexerror( "full table and -cm don't make sense together" ); -X -X*************** -X*** 520,526 **** -X if ( (skelfile = fopen( skelname, "r" )) == NULL ) -X lerrsf( "can't open skeleton file %s", skelname ); -X -X! (void) mktemp( action_file_name ); -X -X if ( (temp_action_file = fopen( action_file_name, "w" )) == NULL ) -X lerrsf( "can't open temporary action file %s", action_file_name ); -X--- 554,562 ---- -X if ( (skelfile = fopen( skelname, "r" )) == NULL ) -X lerrsf( "can't open skeleton file %s", skelname ); -X -X! #ifndef ATARI && LATTICE -X! (void) mktemp( action_file_name ); -X! #endif -X -X if ( (temp_action_file = fopen( action_file_name, "w" )) == NULL ) -X lerrsf( "can't open temporary action file %s", action_file_name ); -X*************** -X*** 566,571 **** -X--- 602,640 ---- -X } -X -X -X+ flexinfo(status) -X+ int status; -X+ { -X+ fprintf(stderr,"Syntax : FLEX inp_file\n"); -X+ fprintf(stderr,"Function: fast lexical analyzer generator V%s\n",flex_version); -X+ fprintf(stderr,"Options : a dir_path : directory path for temporary files\n"); -X+ fprintf(stderr," - b : generate backtracking information to lex.backtrack\n"); -X+ fprintf(stderr," - c : compressed table, no equiv., no meta equiv.classes\n"); -X+ fprintf(stderr," e : equivalence classes\n"); -X+ fprintf(stderr," F : fast table\n"); -X+ fprintf(stderr," |f : full table\n"); -X+ fprintf(stderr," |m : meta equivalence classes\n"); -X+ fprintf(stderr," - d : generate debugging scanner\n"); -X+ fprintf(stderr," - F : fast table\n"); -X+ fprintf(stderr," - f : full (not compressed) table\n"); -X+ fprintf(stderr," - I : generate interactive scanner\n"); -X+ fprintf(stderr," - i : generate case-insensitive scanner\n"); -X+ fprintf(stderr," - L : supress #line directives\n"); -X+ /* fprintf(stderr," - n hexnum : generate scanner using as newline char.\n");*/ -X+ fprintf(stderr," - p : generate performance report to stderr\n"); -X+ fprintf(stderr," - S skeleton_path : file path for skeleton file\n"); -X+ fprintf(stderr," - s : suppress echo of unmatched scanner input to stdout\n"); -X+ fprintf(stderr," - T : run flex in trace mode\n"); -X+ #ifdef ATARI -X+ fprintf(stderr," - t : place result on stdout instead of lex_yy.c\n"); -X+ #else -X+ fprintf(stderr," - t : place result on stdout instead of lex.yy.c\n"); -X+ #endif -X+ fprintf(stderr," - v : print statistics of generated scanner\n"); -X+ fprintf(stderr," default = -cem\n"); -X+ exit(status); -X+ } -X+ -X /* readin - read in the rules section of the input file(s) -X * -X * synopsis -/ -echo x - scan.l_cdiff -sed '/^X/s///' > scan.l_cdiff << '/' -X*** Src_2.1/scan.l Thu Jun 30 19:42:00 1989 -X--- scan.l Thu Jul 2 22:19:26 1989 -X*************** -X*** 125,132 **** -X -X {SCNAME} RETURNNAME; -X ^{OPTWS}\n ++linenum; /* allows blank lines in section 1 */ -X! \n ++linenum; return ( '\n' ); -X! . synerr( "illegal character" ); BEGIN(RECOVER); -X -X -X "*/" ECHO; BEGIN(0); -X--- 125,136 ---- -X -X {SCNAME} RETURNNAME; -X ^{OPTWS}\n ++linenum; /* allows blank lines in section 1 */ -X! {OPTWS}\n ++linenum; return ( '\n' ); -X! . { -X! synerr( "illegal character" ); -X! fprintf(stderr,"Char : $%x\n",yytext[yyleng-1]); -X! BEGIN(RECOVER); -X! } -X -X -X "*/" ECHO; BEGIN(0); -X*************** -X*** 206,212 **** -X ^{OPTWS}\n ++linenum; /* allow blank lines in section 2 */ -X -X /* this horrible mess of a rule matches indented lines which -X! * do not contain "/*". We need to make the distinction because -X * otherwise this rule will be taken instead of the rule which -X * matches the beginning of comments like this one -X */ -X--- 210,216 ---- -X ^{OPTWS}\n ++linenum; /* allow blank lines in section 2 */ -X -X /* this horrible mess of a rule matches indented lines which -X! * do not contain '/','*'. We need to make the distinction because -X * otherwise this rule will be taken instead of the rule which -X * matches the beginning of comments like this one -X */ -/ -echo x - Makefile.tos -sed '/^X/s///' > Makefile.tos << '/' -X# make file for "flex" tool -X -X# @(#) $Header$ (LBL) -X -X# Porting considerations: -X# -X# For System V Unix machines, add -DSYS_V to CFLAGS. -X# For Vax/VMS, add -DSYS_V to CFLAGS. -X# For MS-DOS, add "-DMS_DOS -DSYS_V" to CFLAGS. Create \tmp if not present. -X# You will also want to rename flex.skel to something with a three -X# character extension, change SKELETON_FILE below appropriately, -X# For Amiga, add "-DAMIGA -DSYS_V" to CFLAGS. -X# -X# A long time ago, flex was successfully built using Microsoft C and -X# the following options: /AL, /stack:10000, -LARGE, -Ml, -Mt128, -DSYS_V -X -X -X# the first time around use "make first_flex" -X -X# The following definitions must be set according to your compiler - -X# examples for a Lattice Compiler with GST assembler and TURBO C with -X# assembler are provided below and must just be updated (don't forget to -X# update the linker argument extension files (*.lnk,*.tlk), too) : -X# -X#CCPATH = path to compiler directory without trailing \ -X#CHPATH = path to header files without trailing \ -X#CC = filename of the compiler -X#CFLAGS = compiler option flags -X#CIEXT = extension of C sources that should be used for input filenames -X#ASMPATH = path to assembler directory without trailing \ -X#ASM = filename of the assembler -X#AFLAGS = assembler option flags -X#AIEXT = extension of assembler sources that should be used for assembler -X# input filenames -X#AEXT = general assembler filename extension -X#LNKPATH = path to linker directory without trailing \ -X#LINK = filename of the linker -X#LFLAG0 = first option (full pathname of C startupcode) -X#LFLAG1 = further options + option flag for argument extension filename -X#LFLAG2 = further options + option flag for output-filename -X#LNKEXT = extension of linker argument extension file -X#OIEXT = extension of objects that should be used for linker input files -X#OEXT = general object file extension -X -X# Lattice definitions -XCCPATH = d:\latt -XCHPATH = d:\latt\include -XCC = lc.ttp -XCFLAGS = -h -n -cw -cc -i$(CHPATH)\ -g$(CCPATH)\ -dLATTICE -dATARI -XCIEXT = -XASMPATH = d:\gst -XASM = assem.ttp -XAFLAGS = -nolist -errors errors.out -XAIEXT = -XAEXT = .asm -XLNKPATH = d:\gst -XLINK = ld.ttp -XLFLAG0 = -XLFLAG1 = -with -XLFLAG2 = -nolist -sec -mem 200 -prog -XLNKEXT = .lnk -XOIEXT = -XOEXT = .bin -X -X# Turbo definitions -X#CCPATH = d:\turbo -X#CHPATH = d:\turbo\include -X#CC = tcc.prg -X#CFLAGS = -GJMPRZ -H=$(CHPATH)\ -w- -DTURBO -DATARI -X#CIEXT = .c -X#ASMPATH = d:\turbo -X#ASM = mas.prg -X#AFLAGS = -X#AIEXT = .s -X#AEXT = .s -X#LNKPATH = d:\turbo -X#LINK = tlink.ttp -X#LFLAG0 = $(LNKPATH)\lib\tcstart.o -X#LFLAG1 = -I= -X#LFLAG2 = -O= -X#LNKEXT = .tlk -X#OIEXT = .o -X#OEXT = .o -X -X# Other definitions -X# (not used for Atari because of short argument string - defined in flexdef.h -X -XSKELETON_DIR = /usr/lib -XSKELETON_FILE = flex.skel -XSKELFLAGS = -DDEFAULT_SKELETON_FILE=\"$(SKELETON_DIR)/$(SKELETON_FILE)\" -X -X -XFLEX = d:\etc\flex.ttp -XFLEX_FLAGS = -is -XYACC = d:\etc\yacc.ttp -XRENAME = d:\bin\rename -XDEL = d:\bin\del -X -X# Internal definitions -XLNK = $(LNKPATH)\$(LINK) -X -XFLEXOBJS = \ -X ccl$(OEXT) \ -X dfa$(OEXT) \ -X ecs$(OEXT) \ -X gen$(OEXT) \ -X main$(OEXT) \ -X misc$(OEXT) \ -X nfa$(OEXT) \ -X parse$(OEXT) \ -X scan$(OEXT) \ -X sym$(OEXT) \ -X tblcmp$(OEXT) \ -X yylex$(OEXT) -X -XFLEX_C_SOURCES = \ -X ccl.c \ -X dfa.c \ -X ecs.c \ -X gen.c \ -X main.c \ -X misc.c \ -X nfa.c \ -X parse.c \ -X scan.c \ -X sym.c \ -X tblcmp.c \ -X yylex.c -X -Xflex : $(FLEXOBJS) -X $(LNK) $(LFLAG0) $(LFLAG1)flex$(LNKEXT) $(LFLAG2)flex.ttp -X -Xfirst_flex: -X cp initscan.c scan.c -X make $(MFLAGS) flex -X -Xparse.h parse.c : parse.y -X $(YACC) -d parse.y -X $(DEL) parse.c -X $(RENAME) y_tab.c parse.c -X $(DEL) parse.h -X $(RENAME) y_tab.h parse.h -X -Xscan.c : scan.l -X $(FLEX) $(FLEX_FLAGS) scan.l -X $(RENAME) lex_yy.c scan.c -X -Xscan$(OEXT) : scan.c parse.h flexdef.h -X $(CCPATH)\$(CC) $(CFLAGS) scan$(CIEXT) -X -Xmain$(OEXT) : main.c flexdef.h -X $(CCPATH)\$(CC) $(CFLAGS) main$(CIEXT) -X -Xccl$(OEXT) : ccl.c flexdef.h -X $(CCPATH)\$(CC) $(CFLAGS) ccl$(CIEXT) -X -Xdfa$(OEXT) : dfa.c flexdef.h -X $(CCPATH)\$(CC) $(CFLAGS) dfa$(CIEXT) -X -Xecs$(OEXT) : ecs.c flexdef.h -X $(CCPATH)\$(CC) $(CFLAGS) ecs$(CIEXT) -X -Xgen$(OEXT) : gen.c flexdef.h -X $(CCPATH)\$(CC) $(CFLAGS) gen$(CIEXT) -X -Xmisc$(OEXT) : misc.c flexdef.h -X $(CCPATH)\$(CC) $(CFLAGS) misc$(CIEXT) -X -Xnfa$(OEXT) : nfa.c flexdef.h -X $(CCPATH)\$(CC) $(CFLAGS) nfa$(CIEXT) -X -Xparse$(OEXT) : parse.c flexdef.h -X $(CCPATH)\$(CC) $(CFLAGS) parse$(CIEXT) -X -Xsym$(OEXT) : sym.c flexdef.h -X $(CCPATH)\$(CC) $(CFLAGS) sym$(CIEXT) -X -Xtblcmp$(OEXT) : tblcmp.c flexdef.h -X $(CCPATH)\$(CC) $(CFLAGS) tblcmp$(CIEXT) -X -Xyylex$(OEXT) : yylex.c flexdef.h -X $(CCPATH)\$(CC) $(CFLAGS) yylex$(CIEXT) -X -Xflex.man : flex.1 -X nroff -man flex.1 >flex.man -X -Xlint : $(FLEX_C_SOURCES) -X lint $(FLEX_C_SOURCES) > flex.lint -X -Xdistrib : -X mv scan.c initscan.c -X chmod 444 initscan.c -X $(MAKE) $(MFLAGS) clean -X -Xclean : -X rm -f core errs flex *$(OEXT) parse.c *.lint parse.h flex.man tags -X -Xtags : -X ctags $(FLEX_C_SOURCES) -X -Xvms : flex.man -X $(MAKE) $(MFLAGS) distrib -X -Xtest : -X $(FLEX) $(FLEX_FLAGS) scan.l -X $(RENAME) lex_yy.c scan.ctest -X cmp scan.c scan.ctest -X -/ -echo x - Readme2 -sed '/^X/s///' > Readme2 << '/' -XThe changes: (1.7.89 RAL) -X -X - Bug fix: The original flex didn't like trailing spaces in exclusive start -X condition lists ! If you add an trailing space to line 68 in scan.l -X -X "%x SECT2 SECT2PROLOG SECT3 CODEBLOCK PICKUPDEF SC CARETISBOL NUM QUOTE " -X -X you get a misleading error message: -X -X "Syntax error at line 69: bad start condition list" -X -X This bug can either be fixed in parse.y or in scan.l . I have chosen the -X last because there the fix is minimal: Just change the rule (line 128) -X -X "\n" to "{OPTWS}\n" -X -X - Enhancements: -X - new option "-?" that provides some help information about the other -X flags (main.c) -X - new option "-aTMPPATH" that allows a redefinition of the standard -X path for the temporary file (this might be rather large >200k if -X F,f options are selected). (main.c, flexdef.h (l.376)) -X - hexdump of illegal characters -- this proved to be a useful debugging -X tool especialy if invisible control characters occur which weren't -X covered by the rules. (scan.l fprintf statement line 129,...) -X -X - Patches due to TOS -X - General: TOS uses CR,LF as end of line char., Flex wants only a single -X LF as EOL char. Therefore all I/O must be translated using f* calls. -X This is done everywhere besides the YY_INPUT macro (flex.skel (scan.c), -X line 31) that uses a low level 'read'. This should be definitly changed -X to fread, so that all I/O calls occur on the same level. -X - the short action_file_name has been "flexXXXXXX.tmp", but that's too -X much for TOS,MSDOS ! I changed it to "flexXXXX.tmp" in main.c (patch -X covered by the -a option additions) -X - some compilers don't like external names that are ambiguous within -X the first 8 characters. I defined macros that change all these long -X external names to names that are unique within the first 8 characters. -X Just define SHORT_EXTERNAL_NAMES to use this feature (flexdef.h) -X - some statement changes that some compiler don't like: -X typedef *xxx[] -> typedef **xxx (flexdef.h.,l.308) -X "/*" -> '/','*' within a comment in (scan.l, l.209) -X - changed short "lexyy.c" to "lex_yy.c" what's more similar to the unix -X "lex.yy.c" (main.c). -X - a few further really compiler dependent changes provided with -X #ifdef ATARI && LATTICE res. TURBO braces. -X -X - Additional TOS only files -X - Makefile.tos: Common makefile for all TOS compilers. If you add further -X ones please email me the new makefile. -X - flex.lnk: Lattice - GST linker argument extension file -X - flex.tlk: Turbo linker argument extension file -X -X -XAdditional remarks: -X -XI didn't add a new initscan.c (= flex -ist scan.l). The current one is good -Xenough for a first compilation. With this first version of flex you can -Xrebuild your own scan.c and the final flex version ! -X -XMinix ST : -X - I had to "chmem =70000 cv" (>50000) to get flex linked -X - 'memset' (PC 1.3, EFTH40,...) is necessary -X - chmem =90000 flex may be sufficient -X -XMinix PC : -X It should be possible to port Flex to Minix PC. The current sizes of flex -X are: -X Minix ST (ACK) Lattice (TOS) Turbo (TOS) -X -X size 75300 83305 57957 -X compilation time 22' 15' 3'40" -X flex -is scan.l 1'49" 43" 30" -X -X The Minix ST size includes the bad generated code using only a subset of -X the 68000 commands, long addresses only and a huge relocation table. -X Therefore the PC size will be <64 k ! More serious is the fact that I had -X to chmem =90000 flex to get scan.l converted to scan.c . But I never saw -X a more complex lex source than scan.l -- so it should be possible to -X reduce some array sizes without limitation for all day usage. -X -X No one volunteered yet for a Minix PC port -- but if someone will try it -X I would provide him with a new scan.c and some hints. -X -XTOS: -X Don't forget to adapt the flexskel path within flexdef.h ! -X -X -/ -echo x - flex.lnk -sed '/^X/s///' > flex.lnk << '/' -X* -X* -X* linker control file for flex.ttp -X* -X* -X* -XINPUT d:\latt\lib\startup.bin -X* -XINPUT ccl.bin -XINPUT dfa.bin -XINPUT ecs.bin -XINPUT gen.bin -XINPUT misc.bin -XINPUT nfa.bin -XINPUT parse.bin -XINPUT sym.bin -XINPUT tblcmp.bin -XINPUT main.bin -XINPUT yylex.bin -XINPUT scan.bin -X* -XLIBRARY d:\latt\lib\clib.bin -X -/ -echo x - flex.tlk -sed '/^X/s///' > flex.tlk << '/' -Xccl.o -Xdfa.o -Xecs.o -Xgen.o -Xmisc.o -Xnfa.o -Xparse.o -Xsym.o -Xtblcmp.o -Xyylex.o -Xmain.o -Xscan.o -Xd:\turbo\lib\tcstdlib.lib ; standard lib -Xd:\turbo\lib\tcextlib.lib ; extended lib -Xd:\turbo\lib\tctoslib.lib ; TOS lib -Xd:\turbo\lib\tcgemlib.lib ; AES and VDI lib -X-S=200000 -/ diff --git a/commands/flex-2.5.4/MISC/Borland.old/Borland-2.4 b/commands/flex-2.5.4/MISC/Borland.old/Borland-2.4 deleted file mode 100644 index bb18909a5..000000000 --- a/commands/flex-2.5.4/MISC/Borland.old/Borland-2.4 +++ /dev/null @@ -1,419 +0,0 @@ -Received: from 128.140.1.1 by ee.lbl.gov for (8.6.9/1.43r) - id HAA01193; Thu, 29 Sep 1994 07:26:54 -0700 -Received: from larry-le0.cc.emory.edu by - emoryu1.cc.emory.edu (5.65/Emory_cc.4.0.1) via SMTP - id AA07292 ; Thu, 29 Sep 94 10:26:41 -0400 -From: tkane01@unix.cc.emory.edu (Terrence O Kane) -Received: by larry.cc.emory.edu (5.0) id AA11757; Thu, 29 Sep 1994 10:26:43 +0500 -Message-Id: <9409291426.AA11757@larry.cc.emory.edu> -Subject: patches and makefile for Borland C 4.02, flex 2.4.7 -To: vern@ee.lbl.gov -Date: Thu, 29 Sep 1994 10:26:42 -0400 (EDT) -X-Mailer: ELM [version 2.4 PL23] -Mime-Version: 1.0 -Content-Type: text/plain; charset=US-ASCII -Content-Transfer-Encoding: 7bit -Content-Length: 9900 - -Enclosed are unified diffs and a makefile for Borland 4.02 - -The changes in the enclosed are 1) make the size parameters for memory -allocation "size_t", 2) change an include file when the lexer is -compiled within 'extern "C" {...}' in a C++ file, and 3) include pragmas -in the header suitable for BCC 4.02 to hush on warnings. - -The latter is done because of the limit on command line size. A tradeoff -exists between putting pragmas in the header, or #defines in the header - -I put in the pragmas since they're suppoed to be ignored unless -understood - *and* they're enclosed in BCC specific ifdefs, anyway. - -All changes are enclosed in "#ifdef __BORLANDC__". - - - - - ---- misc.c Tue Jan 04 14:33:10 1994 -+++ ../misc.c Wed Sep 28 18:44:32 1994 -@@ -55,15 +55,19 @@ - action_index += len; - } - - - /* allocate_array - allocate memory for an integer array of the given size */ - - void *allocate_array( size, element_size ) -+#ifndef __BORLANDC__ - int size, element_size; -+#else /* __BORLANDC__ */ -+size_t size, element_size; -+#endif /* __BORLANDC__ */ - { - register void *mem; - - /* On 16-bit int machines (e.g., 80286) we might be trying to - * allocate more than a signed int can hold, and that won't - * work. Cheap test: - */ -@@ -634,15 +638,19 @@ - } - - - /* reallocate_array - increase the size of a dynamic array */ - - void *reallocate_array( array, size, element_size ) - void *array; -+#ifndef __BORLANDC__ - int size, element_size; -+#else /* __BORLANDC__ */ -+size_t size, element_size; -+#endif /* __BORLANDC__ */ - { - register void *new_array; - - /* Same worry as in allocate_array(): */ - if ( size * element_size <= 0 ) - flexfatal( - "attempt to increase array size by less than 1 byte" ); -@@ -739,15 +747,19 @@ - } - - - /* The following is only needed when building flex's parser using certain - * broken versions of bison. - */ - void *yy_flex_xmalloc( size ) -+#ifndef __BORLANDC__ - int size; -+#else /* __BORLANDC__ */ -+size_t size; -+#endif /* __BORLANDC__ */ - { - void *result = flex_alloc( size ); - - if ( ! result ) - flexfatal( "memory allocation failed in yy_flex_xmalloc()" ); - - return result; - - - - - ---- skel.c Wed Aug 03 11:38:32 1994 -+++ ../skel.c Wed Sep 28 18:50:58 1994 -@@ -26,15 +26,19 @@ - "", - "#ifdef __cplusplus", - "", - "#include ", - "%+", - "class istream;", - "%*", -+ "#ifndef __BORLANDC__", - "#include ", -+ "#else /* __BORLANDC__ */", -+ "#include ", -+ "#endif /* __BORLANDC__ */", - "", - "/* Use prototypes in function declarations. */", - "#define YY_USE_PROTOS", - "", - "/* The \"const\" storage-class-modifier is valid. */", - "#define YY_USE_CONST", - "", -@@ -240,16 +244,21 @@ - "static int yy_start_stack_depth = 0;", - "static int *yy_start_stack = 0;", - "static void yy_push_state YY_PROTO(( int new_state ));", - "static void yy_pop_state YY_PROTO(( void ));", - "static int yy_top_state YY_PROTO(( void ));", - "%*", - "", -+ "#ifndef __BORLANDC__", - "static void *yy_flex_alloc YY_PROTO(( unsigned int ));", - "static void *yy_flex_realloc YY_PROTO(( void *, unsigned int ));", -+ "#else /* __BORLANDC__ */", -+ "static void *yy_flex_alloc YY_PROTO(( size_t ));", -+ "static void *yy_flex_realloc YY_PROTO(( void *, size_t ));", -+ "#endif /* __BORLANDC__ */", - "static void yy_flex_free YY_PROTO(( void * ));", - "", - "#define yy_new_buffer yy_create_buffer", - "", - "%% yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here", - "", - "#ifndef yytext_ptr", - - - - - ---- initscan.c Wed Aug 03 11:42:46 1994 -+++ ../initscan.c Wed Sep 28 18:51:34 1994 -@@ -16,15 +16,19 @@ - #endif - #endif - - - #ifdef __cplusplus - - #include -+#ifndef __BORLANDC__ - #include -+#else /* __BORLANDC__ */ -+#include -+#endif /* __BORLANDC__ */ - - /* Use prototypes in function declarations. */ - #define YY_USE_PROTOS - - /* The "const" storage-class-modifier is valid. */ - #define YY_USE_CONST - -@@ -220,16 +224,21 @@ - static int yy_start_stack_ptr = 0; - static int yy_start_stack_depth = 0; - static int *yy_start_stack = 0; - static void yy_push_state YY_PROTO(( int new_state )); - static void yy_pop_state YY_PROTO(( void )); - static int yy_top_state YY_PROTO(( void )); - -+#ifndef __BORLANDC__ - static void *yy_flex_alloc YY_PROTO(( unsigned int )); - static void *yy_flex_realloc YY_PROTO(( void *, unsigned int )); -+#else /* __BORLANDC__ */ -+static void *yy_flex_alloc YY_PROTO(( size_t )); -+static void *yy_flex_realloc YY_PROTO(( void *, size_t )); -+#endif /* __BORLANDC__ */ - static void yy_flex_free YY_PROTO(( void * )); - - #define yy_new_buffer yy_create_buffer - - #define INITIAL 0 - #define SECT2 1 - #define SECT2PROLOG 2 - - - - - ---- flexdef.h Tue Jan 04 14:33:14 1994 -+++ ../flexdef.h Wed Sep 28 18:53:44 1994 -@@ -27,14 +27,25 @@ - */ - - /* @(#) $Header$ (LBL) */ - - #include - #include - -+#ifdef __BORLANDC__ -+#include -+ -+#pragma warn -pro -+#pragma warn -rch -+#pragma warn -use -+#pragma warn -aus -+#pragma warn -par -+#pragma warn -pia -+ -+#endif /* __BORLANDC__ */ - #if HAVE_STRING_H - #include - #else - #include - #endif - - #if __STDC__ -@@ -607,19 +618,29 @@ - */ - - extern char nmstr[MAXLINE]; - extern int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs; - extern int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave; - extern int num_backing_up, bol_needed; - -+#ifndef __BORLANDC__ - void *allocate_array PROTO((int, int)); - void *reallocate_array PROTO((void*, int, int)); -+#else /* __BORLANDC__ */ -+void *allocate_array PROTO((size_t, size_t)); -+void *reallocate_array PROTO((void*, size_t, size_t)); -+#endif /* __BORLANDC__ */ - -+#ifndef __BORLANDC__ - void *flex_alloc PROTO((unsigned int)); - void *flex_realloc PROTO((void*, unsigned int)); -+#else /* __BORLANDC__ */ -+void *flex_alloc PROTO((size_t)); -+void *flex_realloc PROTO((void*, size_t)); -+#endif /* __BORLANDC__ */ - void flex_free PROTO((void*)); - - #define allocate_integer_array(size) \ - (int *) allocate_array( size, sizeof( int ) ) - - #define reallocate_integer_array(array,size) \ - (int *) reallocate_array( (void *) array, size, sizeof( int ) ) -@@ -772,15 +793,19 @@ - /* Write out one section of the skeleton file. */ - extern void skelout PROTO((void)); - - /* Output a yy_trans_info structure. */ - extern void transition_struct_out PROTO((int, int)); - - /* Only needed when using certain broken versions of bison to build parse.c. */ -+#ifndef __BORLANDC__ - extern void *yy_flex_xmalloc PROTO(( int )); -+#else /* __BORLANDC__ */ -+extern void *yy_flex_xmalloc PROTO(( size_t )); -+#endif /* __BORLANDC__ */ - - /* Set a region of memory to 0. */ - extern void zero_out PROTO((char *, int)); - - - /* from file nfa.c */ - - - - - -############################################################################### -# Makefile for flex 2.4.7 with Borland C/C++ version 4.02 -# -# This will probably need to be adjusted for your existing lexer/parser -# generators. See definitions for FLEX and YACC near the bottom of the -# makefile. -# -# Copy initscan.c to scan.c to make your first executable. After that, -# you may choose to try alternate compression options for your everyday -# flex executable. -# -# This will build flex with the large model. Don't use huge, but if you -# feel like experimenting with other models, post your success stories to -# comp.compilers, OK? -# -# This makefile does *not* implement the big testing found in "makefile.in". -# -# I also assume the availability of sed and the gnu file utilities on the -# system - they're readily available, so if you don't have them, why not? -# -# -# The resulting generated lexer (the real goal, right?) will compile -# (and run nicely, too) as a .c file, as well as being included such as -# extern "C" { #include "lexyyc" } in a .cplusplus file. -# -############################################################################### - -DEBUG = 1 - -.autodepend - -all: flex.exe - -############################################################################### -# -# standard utilitities? ha. -# - -CC = bcc -CPP = bcc - -############################################################################### -# - -MODEL = l - -!if $(DEBUG) == 1 -!message Building with debug. -debugCompile = -v -debugLink = /v -!else -!message Building without debug. -debugCompile = -debugLink = -!endif - -LOADER = c0$(MODEL).obj -LIBS = c$(MODEL).lib -LINKFLAGS = $(debugLink) - -DATASEG = -dc -Ff -SizeOPT = -Os -G- -Defines = -DSHORT_FILE_NAMES=1 -DHAVE_STRING_H=1 - -COMMON = -A -c -m$(MODEL) $(SizeOPT) $(DATASEG) $(Defines) $(debugCompile) -CFLAGS = -o$@ $(COMMON) -CCFLAGS = -o$@ $(COMMON) -Pcc - -############################################################################### - -.SUFFIXES: .cc - -.cc.obj: - $(CPP) $(CCFLAGS) $< - -.c.obj: - $(CPP) $(CFLAGS) $< - -############################################################################### -# -# source & object files -# - -SRC = ccl.c dfa.c ecs.c gen.c main.c misc.c nfa.c parse.c \ - scan.c sym.c tblcmp.c yylex.c skel.c - -OBJS = $(SRC:.c=.obj) - -objects: $(OBJS) - @echo $(OBJS) - -############################################################################### -# -# Executable -# - -flex.exe: $(OBJS) - tlink $(LINKFLAGS) @&&! -$(LOADER) $** -$&.exe -$&.map -$(LIBS) -! - -# -############################################################################### -# -# Lex files -# - -FLEX = .\flex -FLEX_FLAGS = -ist - -scan.c: scan.l - $(FLEX) $(FLEX_FLAGS) scan.l >scan.tmp - sed s,\"$(srcdir)/scan.l\",\"scan.l\", scan.c - @rm scan.tmp - -############################################################################### -# -# YACC files -# - -YACC = .\bison -YFLAGS = -vdyl - -parse.c: parse.y - $(YACC) -ydl parse.y - @sed "/extern char.*malloc/d" parse.c - @rm -f y_tab.c - @mv y_tab.h parse.h - -# -# end Makefile -# -############################################################################### - diff --git a/commands/flex-2.5.4/MISC/Borland.old/Turbo-C b/commands/flex-2.5.4/MISC/Borland.old/Turbo-C deleted file mode 100644 index c15ee6783..000000000 --- a/commands/flex-2.5.4/MISC/Borland.old/Turbo-C +++ /dev/null @@ -1,179 +0,0 @@ -Received: from 128.84.254.220 by ee.lbl.gov for (8.6.8.1/1.43r) - id PAA27266; Mon, 18 Apr 1994 15:08:26 -0700 -Received: from CLOYD.CS.CORNELL.EDU by thialfi.cs.cornell.edu (5.67/I-1.99E) - id AA28742; Mon, 18 Apr 94 18:08:14 -0400 -Received: from iraun1.ira.uka.de by cloyd.cs.cornell.edu (5.67/I-1.99D) - id AA19613; Mon, 18 Apr 94 18:08:19 -0400 -Received: from t500i2.telematik.informatik. (actually t500i2.telematik.informatik.uni-karlsruhe.de) - by iraun1.ira.uka.de with SMTP (PP); Tue, 19 Apr 1994 00:07:55 +0200 -Received: by t500i2.telematik.informatik.uni-karlsruhe.de (5.57/Ultrix3.0-C) - id AA10269; Tue, 19 Apr 94 00:09:14 +0200 -From: beigl@t500i2.telematik.informatik.uni-karlsruhe.de (Michael Beigl) -Message-Id: <9404182209.AA10269@t500i2.telematik.informatik.uni-karlsruhe.de> -Subject: Makefile-TurboC -To: vern@cs.cornell.edu -Date: Tue, 19 Apr 1994 00:09:13 +0200 (MET DST) -X-Mailer: ELM [version 2.4 PL22] -Mime-Version: 1.0 -Content-Type: text/plain; charset=US-ASCII -Content-Transfer-Encoding: 7bit -Content-Length: 2739 - -Hello - -Here are some additional adjustments to my Makefile. I was using "pure" DOS -and an old Turbo C++ 1.0 version, so I had some problems with systemtools -like mv etc. and problems with variables in my Makefile. - -Now follows my Makefile -############################################################################ -# make file for "flex" tool - -# @(#) $Header$ (LBL) - -# Porting considerations: -# -# For BSD machines: -# CFLAGS = -# LDFLAGS = -s -# LINK = $(CC) $(CFLAGS) -o flex $(LDFLAGS) $(FLEXOBJS) -# SKELETON_DIR = . -# SKELETON_FILE = flex.skel -# SKELFLAGS = -DDEFAULT_SKELETON_FILE=\"$(SKELETON_DIR)/$(SKELETON_FILE)\" -# O = o -# YTAB = y.tab -# FLEX = ./flex -# -# For System V Unix or Vax/VMS machines, merely add: -# CFLAGS = -DSYS_V -# -# For MS-DOS, Turbo C: -CC = tcc -# -2+ 286 Options -CFLAGS = -DSYS_V -DMS_DOS -O -G -Z -ml -v -2 -# /3 enable 32 bit processing -# /ye expanded memory swapping -# /yx extended memory swapping -LINK = tlink @flex.lnk/c/x/v/3/ye -SKELETON_DIR = . -SKELETON_FILE = flex.skl -SKELFLAGS = -DDEFAULT_SKELETON_FILE="$(SKELETON_DIR)/$(SKELETON_FILE)" -O = obj -EXE = .exe -YTAB = y_tab -FLEX = flex -YACC = /yacc/byacc - -# -# the first time around use "make first_flex" -# - -FLEX_FLAGS = - -FLEXOBJS = \ - ccl.$O \ - dfa.$O \ - ecs.$O \ - gen.$O \ - main.$O \ - misc.$O \ - nfa.$O \ - parse.$O \ - scan.$O \ - sym.$O \ - tblcmp.$O \ - yylex.$O - -FLEX_C_SOURCES = \ - ccl.c \ - dfa.c \ - ecs.c \ - gen.c \ - main.c \ - misc.c \ - nfa.c \ - parse.c \ - scan.c \ - sym.c \ - tblcmp.c \ - yylex.c - -FLEX_C_SOURCES_1 = \ - ccl.c \ - dfa.c \ - ecs.c \ - gen.c \ - main.c \ - misc.c - -FLEX_C_SOURCES_2 = \ - nfa.c \ - parse.c \ - scan.c \ - sym.c \ - tblcmp.c \ - yylex.c - -flex.exe: $(FLEXOBJS) - $(LINK) - - -flex: $(FLEX_C_SOURCES) - $(CC) $(CFLAGS) -c $(SKELFLAGS) $(FLEX_C_SOURCES_1) - $(CC) $(CFLAGS) -c $(SKELFLAGS) $(FLEX_C_SOURCES_2) - $(LINK) - - -first_flex: - copy initscan.c scan.c - $(MAKE) flex - -parse.h parse.c: parse.y - $(YACC) -d parse.y - @rename $(YTAB).c parse.c - @rename $(YTAB).h parse.h - -scan.c: scan.l - $(FLEX) -ist $(FLEX_FLAGS) scan.l >scan.c - -scan.$O: scan.c parse.h - -main.$O: main.c - $(CC) $(CFLAGS) -c $(SKELFLAGS) main.c - -flex.man: flex.1 - nroff -man flex.1 >flex.man - -lint: $(FLEX_C_SOURCES) - lint $(FLEX_C_SOURCES) > flex.lint - -distrib: - rename scan.c initscan.c - attrib +R -A -H -S initscan.c - $(MAKE) clean - -clean: - del *.obj - del *.lint - del core - del errs - del flex.exe - del parse.c - del parse.h - del flex.man - del tags - -tags: - ctags $(FLEX_C_SOURCES) - -vms: flex.man - $(MAKE) distrib - -test: - $(FLEX) -ist $(FLEX_FLAGS) scan.l | diff scan.c - - -############################################################################ - -I think this Makefile will help some other simple DOS user - - M. Beigl diff --git a/commands/flex-2.5.4/MISC/Borland/Makefile b/commands/flex-2.5.4/MISC/Borland/Makefile deleted file mode 100644 index 3b2009098..000000000 --- a/commands/flex-2.5.4/MISC/Borland/Makefile +++ /dev/null @@ -1,163 +0,0 @@ -############################################################################### -# Makefile for flex 2.5.0.6 (beta) with Borland C/C++ version 4.02 -# -# This will probably need to be adjusted for your existing lexer/parser -# generators. See definitions for FLEX and YACC near the bottom of the -# makefile. -# -# This makefile builds initflex.exe and flex.exe by default. It -# removes initflex.exe after making flex.exe. After that, you may -# choose to try alternate compression options for your everyday flex -# executable. -# -# This will build flex with the large model. Don't use huge, but if you -# feel like experimenting with other models, post your success stories to -# comp.compilers, OK? -# -# This makefile does *not* implement the big testing found in "makefile.in". -# -# I also assume the availability of sed and the gnu file utilities on the -# system - they're readily available, so if you don't have them, why not? -# -# -# The resulting generated lexer (the real goal, right?) will compile -# (and run nicely, too) as a .c file, as well as being included such as -# extern "C" { #include "lexyyc" } in a .cplusplus file. -# -############################################################################### - -DEBUG = 1 - -.autodepend - -all: initflex.exe flex.exe - rm initflex.exe initflex.map - -############################################################################### -# -# standard utilitities? ha. -# - -CC = bcc -CPP = bcc - -############################################################################### -# - -MODEL = l - -!if $(DEBUG) == 1 -!message Building with debug. -debugCompile = -v -debugLink = /v -!else -!message Building without debug. -debugCompile = -debugLink = -!endif - -LOADER = c0$(MODEL).obj -LIBS = c$(MODEL).lib -LINKFLAGS = $(debugLink) - -DATASEG = -dc -Ff -SizeOPT = -Os -G- -Defines = - -COMMON = -A -c -m$(MODEL) $(SizeOPT) $(DATASEG) $(Defines) $(debugCompile) -CFLAGS = -o$@ $(COMMON) -CCFLAGS = -o$@ $(COMMON) -Pcc - -############################################################################### - -.SUFFIXES: .cc - -.cc.obj: - $(CPP) $(CCFLAGS) $< - -.c.obj: - $(CPP) $(CFLAGS) $< - -############################################################################### -# -# source & object files -# - -BASESRC = ccl.c dfa.c ecs.c gen.c main.c misc.c nfa.c parse.c \ - sym.c tblcmp.c yylex.c skel.c - -INITSRC = $(BASESRC) initscan.c - -INITOBJS = $(INITSRC:.c=.obj) - -SRC = $(BASESRC) scan.c - -OBJS = $(SRC:.c=.obj) - -objects: $(OBJS) - @echo $(OBJS) - -############################################################################### -# -# Executable -# - -initflex.exe: $(INITOBJS) - tlink $(LINKFLAGS) @&&! -$(LOADER) $** -$&.exe - -$(LIBS) -! - -flex.exe: $(OBJS) - tlink $(LINKFLAGS) @&&! -$(LOADER) $** -$&.exe - -$(LIBS) -! - -# -############################################################################### -# -# Lex files -# - -FLEX = .\initflex -FLEX_FLAGS = -ist - -scan.c: scan.l - $(FLEX) $(FLEX_FLAGS) scan.l >scan.tmp - sed s,\"$(srcdir)/scan.l\",\"scan.l\", scan.c - @rm scan.tmp - -############################################################################### -# -# YACC files -# - -YACC = .\bison -YFLAGS = -vdyl - -parse.c: parse.y - $(YACC) -ydl parse.y - @sed "/extern char.*malloc/d" parse.c - @rm -f y_tab.c - @mv y_tab.h parse.h - -############################################################################### -# -# cleanup -# - -clean: - -rm *.obj *.map initflex.exe - -realclean: clean - -rm flex.exe - -# -# end Makefile -# -############################################################################### diff --git a/commands/flex-2.5.4/MISC/Borland/NOTES b/commands/flex-2.5.4/MISC/Borland/NOTES deleted file mode 100644 index caac3cc99..000000000 --- a/commands/flex-2.5.4/MISC/Borland/NOTES +++ /dev/null @@ -1,66 +0,0 @@ -Received: from 128.140.1.1 by ee.lbl.gov for (8.6.9/1.43r) - id PAA03966; Tue, 24 Jan 1995 15:03:57 -0800 -Received: from larry-le0.cc.emory.edu by - emoryu1.cc.emory.edu (5.65/Emory_cc.4.0.1) via SMTP - id AA24158 ; Tue, 24 Jan 95 17:18:18 -0500 -From: tkane01@unix.cc.emory.edu (Terrence O Kane) -Received: by larry.cc.emory.edu (5.0) id AA21979; Tue, 24 Jan 1995 17:17:40 -0500 -Message-Id: <9501242217.AA21979@larry.cc.emory.edu> -Subject: Re: Beta test for DOS -To: vern@ee.lbl.gov (Vern Paxson) -Date: Tue, 24 Jan 1995 17:17:38 -0500 (EST) -In-Reply-To: <199501232138.NAA11430@daffy.ee.lbl.gov> from "Vern Paxson" at Jan 23, 95 01:38:02 pm -X-Mailer: ELM [version 2.4 PL23] -Mime-Version: 1.0 -Content-Type: text/plain; charset=US-ASCII -Content-Transfer-Encoding: 7bit -Content-Length: 5792 - -Vern, - -I've made flex 2.5.0.6 successfully with no changes to the source -code at all. I'm including the Borland 4.02 makefile and config.h -at the end of this message. - -When you're ready for release, I'll be happy to take care of getting -the appropriate archive files up to Simtel if you wish. - -I have not used this version for any of my "work-related" scanners -yet, but have run the fastwc benchmark. The compiles were for large -memory model and optimization for fastest possible code. The test -machine was a Pentium-90 (hey! timing output was integer!) with -enhanced IDE on a PCI bus and no file system caching. I ran the -test on two different input files. - -(Times are in seconds.) - -The first input was a typical postscript file concatenated 10 times; -by typical, I mean that there were relatively few spaces, lots of lines -with no space, using lots of parentheses. - - lines words characters - 91200 356260 5889240 - - mywc 8.89 - wc1s 15.22 default - wc1 10.82 -Cf - wc2 10.16 -Cf - wc3 9.17 -Cf - wc4 9.22 -Cf - wc5 10.98 -Cf - -The second test run was on a file that consisted of 20 concatenations -of 'misc/flex.man'. - - lines words characters - 69960 305140 2399960 - - mywc 4.01 - wc1s 6.87 - wc1 5.32 - wc2 4.95 - wc3 4.12 - wc4 4.12 - wc5 5.05 - -[[Makefile and config.h moved to separate files -VP]] diff --git a/commands/flex-2.5.4/MISC/Borland/config.h b/commands/flex-2.5.4/MISC/Borland/config.h deleted file mode 100644 index 256dd7a47..000000000 --- a/commands/flex-2.5.4/MISC/Borland/config.h +++ /dev/null @@ -1,29 +0,0 @@ -/* $Header$ */ -/* ------------------------------------------------ */ -/* version of config.h for Borland C/C++ v4.02 */ -/* flex version 2.5.0.6 (beta) */ -/* ------------------------------------------------ */ - -/* Define to empty if the keyword does not work. */ -#undef const - -/* Define to `unsigned' if doesn't define. */ -#undef size_t - -/* Define if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define if you have the header file. */ -#define HAVE_MALLOC_H 1 - -/* Define if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define if you have and it should be used (not on Ultrix). */ -#undef HAVE_ALLOCA_H - -/* Define if platform-specific command line handling is necessary. */ -#undef NEED_ARGV_FIXUP diff --git a/commands/flex-2.5.4/MISC/EBCDIC b/commands/flex-2.5.4/MISC/EBCDIC deleted file mode 100644 index e4ebd716a..000000000 --- a/commands/flex-2.5.4/MISC/EBCDIC +++ /dev/null @@ -1,48 +0,0 @@ -Return-Path: Mark_Ganter@liz.com -Received: from 192.216.61.11 by horse.ee.lbl.gov for vern (5.65/1.43r) - id AA02152; Tue, 11 Jan 94 06:19:36 -0800 -Received: from melonville.radiomail.net (mayberry.radiomail.net) by radiomail.net with SMTP id AA20220 - (5.65c+/IDA-1.4.4 for ); Tue, 11 Jan 1994 06:19:35 -0800 -Message-Id: <199401111419.AA20220@radiomail.net> -Received: from liz.com by melonville.radiomail.net with CCGW-1.7(930217); - Tue, 11 Jan 94 06:19:17 -From: Mark_Ganter@liz.com -Date: 11 Jan 94 09:05 -To: vern@horse.ee.lbl.gov -Subject: Re[2]: Flex on an AS400 - - I have no problem at all with being a contact for advice - on porting Flex to EBCDIC. The code was put on an AS400, so - filing the message under /MISC/AS400 is more appropriate. - The port was an interesting, very educational experience. - Thanks again. - - - Mark - ------------------------------------------------------------------------- -Date: Tue, 18 Apr 1995 12:33:48 -0400 -To: "Michael W. Duffy" , Mark_Ganter@liz.com, - vern@ee.lbl.gov (Vern Paxson), slayten@cas.org -From: slayten@cas.org (Steve Layten) -Subject: RE: Porting LEX scanner on EBCDIC machine -X-Mailer: -Content-Length: 918 - -I came in late on this discussion - I don't follow comp.compilers very -closely these days because my job has shifted somewhat. - -I ported (quite some time ago) flex 2.3.6 to an IBM 3090 under MVS, using -the SAS C compiler. The approach I used was, as Vern suggested, was to -translate the tables to reflect EBCDIC-based indices. I haven't even -downloaded flex 2.4 yet, so I don't know what's in the current distribution. -My patches were in the flex 2.3 distribution for a while in the MISC -directory. If you want any more info feel free to drop me a line - I still -have (somewhere) the patches that I created from version 2.3.6. - -Steve Layten --- -Steven W. Layten, Senior Research Scientist -Chemical Abstracts Service PO BOX 3012, Columbus, OH 43210 +1 614 447 3600 -INET: slayten@cas.org FAX: +1 614 447 3813 -# # Speaking only for myself, and NOT for Chemical Abstracts Service! # # # diff --git a/commands/flex-2.5.4/MISC/MSDOS/MSC70.make b/commands/flex-2.5.4/MISC/MSDOS/MSC70.make deleted file mode 100644 index 5980f3a61..000000000 --- a/commands/flex-2.5.4/MISC/MSDOS/MSC70.make +++ /dev/null @@ -1,115 +0,0 @@ -# -# make file for "flex" tool -# @(#) $Header: /usr/fsys/odin/a/vern/flex/RCS/Makefile,v 2.9 90/05/26 17:28:44 - vern Exp $ (LBL) -# -# the first time around use "make f_flex" -# -# This makefile is specific for Microsoft's C/C++ compiler (v7), nmake and -# lib -# - Paul Stuart, Jan 93 (pjs@scammell.ecos.tne.oz.au) -# - - -SKELFLAGS = -DDEFAULT_SKELETON_FILE=\"c:/src/flex/flex.skl\" -CFLAGS = -nologo -AL -W2 -F 8000 -Ox -Gt16000 -DMS_DOS -DUSG -LDFLAGS = /nologo /NOI /BATCH /ONERROR:NOEXE /STACK:8000 -FLEX_FLAGS = -ist8 -Sflex.skl - -FLEX = .\flex.exe -CC = cl -YACC = c:\lib\byacc -MAKE = nmake /nologo - -# -# break obj-list into two because of 128 character command-line limit of -# Microsoft's link and lib utilities. -# -FLEXOBJS1 = \ - ccl.obj \ - dfa.obj \ - ecs.obj \ - gen.obj \ - main.obj \ - misc.obj \ - nfa.obj \ - parse.obj - -FLEXOBJS2 = \ - scan.obj \ - sym.obj \ - tblcmp.obj \ - yylex.obj - -FLEX_C_SOURCES = \ - ccl.c \ - dfa.c \ - ecs.c \ - gen.c \ - main.c \ - misc.c \ - nfa.c \ - parse.c \ - scan.c \ - sym.c \ - tblcmp.c \ - yylex.c - -FLEX_LIB_OBJS = \ - libmain.obj - - -all : flex.exe - -# -# lib is used to get around the 128 character command-line limit of 'link'. -# -flex.exe : $(FLEXOBJS1) $(FLEXOBJS2) - lib /nologo tmplib $(FLEXOBJS1); - link $(LDFLAGS) $(FLEXOBJS2),$*.exe,,tmplib; - del tmplib.lib - -f_flex: - copy initscan.c scan.c - touch scan.c - @echo compiling first flex - $(MAKE) flex.exe - del scan.c - @echo using first flex to generate final version... - $(MAKE) flex.exe - -# -# general inference rule -# -.c.obj: - $(CC) -c $(CFLAGS) $*.c - -parse.h parse.c : parse.y - $(YACC) -d parse.y - @mv y_tab.c parse.c - @mv y_tab.h parse.h - -scan.c : scan.l - $(FLEX) $(FLEX_FLAGS) $(COMPRESSION) scan.l >scan.c - - -scan.obj : scan.c parse.h flexdef.h - -main.obj : main.c flexdef.h - $(CC) $(CFLAGS) -c $(SKELFLAGS) main.c - -ccl.obj : ccl.c flexdef.h -dfa.obj : dfa.c flexdef.h -ecs.obj : ecs.c flexdef.h -gen.obj : gen.c flexdef.h -misc.obj : misc.c flexdef.h -nfa.obj : nfa.c flexdef.h -parse.obj : parse.c flexdef.h -sym.obj : sym.c flexdef.h -tblcmp.obj : tblcmp.c flexdef.h -yylex.obj : yylex.c flexdef.h - - -clean : - del *.obj - del *.map diff --git a/commands/flex-2.5.4/MISC/MSDOS/configur.bat b/commands/flex-2.5.4/MISC/MSDOS/configur.bat deleted file mode 100644 index dbea0e467..000000000 --- a/commands/flex-2.5.4/MISC/MSDOS/configur.bat +++ /dev/null @@ -1,6 +0,0 @@ -@echo off - -sed -e "s/y\.tab\./parse_tab\./" -e "/sed/ s/'/\"/g" < Makefile.in > Makefile -sed -f MISC/MSDOS/djgpp.sed Makefile.in > Makefile - -update initscan.c scan.c diff --git a/commands/flex-2.5.4/MISC/MSDOS/djgpp.sed b/commands/flex-2.5.4/MISC/MSDOS/djgpp.sed deleted file mode 100644 index b436113b0..000000000 --- a/commands/flex-2.5.4/MISC/MSDOS/djgpp.sed +++ /dev/null @@ -1,12 +0,0 @@ -s/y\.tab\./parse_tab\./ -s/@DEFS@/-DMS_DOS/ -s/@LIBS@// -s/@srcdir@/./ -s/@YACC@/bison/ -s/@CC@/gcc/ -s/@RANLIB@/ranlib/ -s/@ALLOCA@// -/^flex/ s/\.bootstrap// -/sed.*extern.*malloc/ c\ - @mv parse_tab.c parse.c -/rm.*parse_tab.c/ d diff --git a/commands/flex-2.5.4/MISC/MVS/MVS.mail b/commands/flex-2.5.4/MISC/MVS/MVS.mail deleted file mode 100644 index 5a75e5b57..000000000 --- a/commands/flex-2.5.4/MISC/MVS/MVS.mail +++ /dev/null @@ -1,56 +0,0 @@ -(Message inbox:40) -Date: Tue, 17 Jul 1990 11:56 EDT -From: swl26%CAS.BITNET@CORNELLC.cit.cornell.edu -Subject: Re(2): port of flex-2.3 to IBM/MVS -To: vern@cs.cornell.edu - ->Message received. I'm sending this response to ->swl26%CAS.BITNET@CORNELLC.cit.cornell.edu. - -Great -- we can talk. - ->How extensive are the diffs? If they're fairly short then yes, please ->send them. If they're pretty involved then probably not, as I'm not aware ->of many MVS flex users ... - -I've built a context diff file which is ~850 lines. - -Summary of major changes necessary: - - o a new initscan.c -- because MVS is ebcdic, the initial scanner had - to be changed. I built a scanner from scan.l using -Ce, then - hand-manipulated the yy_ec table to fit EBCDIC instead of ASCII - chars. (This is not included in the diff file above.) - - o changes in main and flexdef.h to change how files are handled. (No - dynamic file names, etc.) - - o Some lines had to be shortened to 80 bytes. This mostly impacted - your RCSID lines, which with the full path name were too long. - - o SASC and the linker don't allow externals to be longer than 8 chars. - I thus wrote a Q&D program to shorten all externals. (This would be - a separate file 'fixit.l', which is not included in the diffs.) - - o There are several places where there are tests for 'isascii' (which I - deleted conditionally, using #ifdefs), and tests for 'A' <= x <= 'Z' - which I changed to 'isupper'. - -Many of the changes I've incorporated without impacting other systems. -Others are with 'ifdefs'. Still others (the short external names and new -initscan) are 'isolable' as separate files which would have to be -included with a distribution. - -Obviously, you are not going to want to (even if you can :-) ) worry about -testing new versions in the MVS environment. Likewise, I don't have the -time or resources to provide much support. (I'm not sure my management -would allow any :-( ) - -With all of the above feel free to say "Thanks, but no thanks." If you -want to see the diffs anyway, I will certainly mail them. - -Thanks for your time and efforts. - -Steve Layten -Chemical Abstracts Service, PO Box 3012, Columbus, OH 43210, +1 614 421-3600 -INET: swl26%cas.BITNET@CUNYVM.CUNY.Edu diff --git a/commands/flex-2.5.4/MISC/MVS/MVS.todo b/commands/flex-2.5.4/MISC/MVS/MVS.todo deleted file mode 100644 index b6060eca4..000000000 --- a/commands/flex-2.5.4/MISC/MVS/MVS.todo +++ /dev/null @@ -1,23 +0,0 @@ -(Message inbox:47) -Date: Wed, 18 Jul 1990 14:16 EDT -From: swl26%CAS.BITNET@CORNELLC.cit.cornell.edu -Subject: Re(2): Re(2): diffs for mvs port of flex-2.3 -To: vern@cs.cornell.edu - - - ->Thanks, I've successfully unpacked the archive. I may simply distribute ->the diffs as a set of files in the MISC/ directory rather than incorporating ->them into the 2.4 release. Let me know if you don't want me to do so. -> -> Vern - - -Thank you! What you propose is okay. I might suggest, however, that you -look in the diffs for dfa.c, misc.c, and yylex.c, and consider removing -some of the ASCIIisms which are probably unnecessary. The manner in -which I made the changes was pure brute force, and there might be a -better way, but the changes I made there shouldn't hurt anything. - - regards, - Steve diff --git a/commands/flex-2.5.4/MISC/MVS/MVS.uudecode b/commands/flex-2.5.4/MISC/MVS/MVS.uudecode deleted file mode 100644 index 2b8e802ae..000000000 --- a/commands/flex-2.5.4/MISC/MVS/MVS.uudecode +++ /dev/null @@ -1,341 +0,0 @@ -Received: from CU-ARPA.CS.CORNELL.EDU by loki.cs.cornell.edu (5.61/I-1.91f) - id AA25874; Wed, 18 Jul 90 12:02:22 -0400 -Message-Id: <9007181320.AA24810@cu-arpa.cs.cornell.edu> -Received: from CORNELLC.CIT.CORNELL.EDU by cu-arpa.cs.cornell.edu (5.61+2/1.91d) - id AA24810; Wed, 18 Jul 90 09:20:21 -0400 -Received: from CORNELLC by CORNELLC.cit.cornell.edu (IBM VM SMTP R1.2.1MX) with BSMTP id 6769; Wed, 18 Jul 90 09:18:46 EDT -Received: from CAS.BITNET (MAILER) by CORNELLC (Mailer R2.05X) with BSMTP id - 5378; Wed, 18 Jul 90 09:18:38 EDT -From: swl26%CAS.BITNET@CORNELLC.cit.cornell.edu -Date: Wed, 18 Jul 1990 09:16 EDT -Subject: Re(2): diffs for mvs port of flex-2.3 -In-Reply-To: Your message of Tue, 17 Jul 90 17:42:3 -To: vern@cs.cornell.edu - -Sorry about the trailing blank problem. It's farily common with data sent -through bitnet paths, but ever the optimist ... - ->I think there should be an 'M' at the beginning of the second line. - -This isn't a problem. I believe that the first byte of the line indicates -it's length (in some manner). - -Rather than re-send the data, how about a uudecode that compensates for -the trailing blank problem? I manually mangled the uuencoded file and ran -the following decode, and it seemed to work. - -#! /bin/sh -# This is a shell archive. Remove anything before this line, then feed it -# into a shell via "sh file" or similar. To overwrite existing files, -# type "sh file -c". -# The tool that generated this appeared in the comp.sources.unix newsgroup; -# send mail to comp-sources-unix@uunet.uu.net if you want that tool. -# If this archive is complete, you will see the following message at the end: -# "End of shell archive." -# Contents: uudecode.c -# Wrapped by swl26@swl26aws on Wed Jul 18 08:59:24 1990 -PATH=/bin:/usr/bin:/usr/ucb ; export PATH -if test -f 'uudecode.c' -a "${1}" != "-c" ; then - echo shar: Will not clobber existing file \"'uudecode.c'\" -else -echo shar: Extracting \"'uudecode.c'\" \(6418 characters\) -sed "s/^X//" >'uudecode.c' <<'END_OF_FILE' -X/* #ifndef lint -Xstatic char sccsid[] = "@(#)uudecode.c 5.3-1 (Berkeley) 9/1/87"; -X#endif */ -X -X/* Written by Mark Horton */ -X/* Modified by ajr (Alan J Rosenthatl,flaps@utcsri.UUCP) to use checksums */ -X/* Modified by fnf (Fred Fish,well!fnf) to use Keith Pyle's suggestion for -X compatibility */ -X/* Modified by bcn (Bryce Nesbitt,ucbvax!cogsci!bryce) to fix a misleading -X error message on the Amiga port, to fix a bug that prevented decoding -X certain files, to work even if trailing spaces have been removed from a -X file, to check the filesize (if present), to add some error checking, to -X loop for multiple decodes from a single file, and to handle common -X BITNET mangling. Also kludged around a missing string function in Aztec -X C */ -X -X/* -X * uudecode [input] -X * -X * Decode a file encoded with uuencode. WIll extract multiple encoded -X * modules from a single file. Can deal with most mangled files, including -X * BITNET. -X */ -X -X#include -X#include -X -X#ifdef AMIGA -X#define AMIGA_LATTICE /* Set for Amiga Lattice C */ -X#define MCH_AMIGA -X#define MPU68000 -X#endif -X -X#ifdef unix -X#include -X#include -X#include -X#endif -X -X#define SUMSIZE 64 -X#define DEC(c) (((c) - ' ') & 077) /* single character decode */ -X -Xmain(argc, argv) -Xchar **argv; -X{ -XFILE *in, *out; -Xint through_loop=0; /* Dejavu indicator */ -Xint mode; /* file's mode (from header) */ -Xlong filesize; /* theoretical file size (from header) */ -Xchar dest[128]; -Xchar buf[80]; -X -X#ifdef AMIGA_LATTICE -Xextern int Enable_Abort; -X Enable_Abort=1; -X#endif -X -X /* A filename can be specified to be uudecoded, or nothing can -X be specified, and the input will come from STDIN */ -X -X switch (argc) -X { -X case 1: -X in=stdin; -X break; -X -X case 2: -X if ((in = fopen(argv[1], "r")) == NULL) -X { -X fprintf(stderr, "ERROR: can't find %s\n", argv[1]); -X fprintf(stderr, "USAGE: uudecode [infile]\n"); -X exit(10); -X } -X break; -X -X default: -X fprintf(stderr, "USAGE: uudecode [infile]\n"); -X exit(11); -X break; -X } -X -X /* Loop through file, searching for headers. Decode anything with a -X header, complain if there where no headers. */ -X -Xfor (;;) -X{ -X /* search file for header line */ -X for (;;) -X { -X if (fgets(buf, sizeof buf, in) == NULL) -X { -X if (!through_loop) -X { -X fprintf(stderr, "ERROR: no `begin' line!\n"); -X exit(12); -X } -X else -X { -X exit(0); -X } -X } -X if (strncmp(buf, "begin ", 6) == 0) -X break; -X } -X sscanf(buf, "begin %o %s", &mode, dest); -X -X#ifdef unix -X /* handle ~user/file format */ -X if (dest[0] == '~') -X { -X char *sl; -X struct passwd *getpwnam(); -X char *index(); -X struct passwd *user; -X char dnbuf[100]; -X -X sl = index(dest, '/'); -X if (sl == NULL) -X { -X fprintf(stderr, "Illegal ~user\n"); -X exit(13); -X } -X *sl++ = 0; -X user = getpwnam(dest+1); -X if (user == NULL) -X { -X fprintf(stderr, "No such user as %s\n", dest); -X exit(14); -X } -X strcpy(dnbuf, user->pw_dir); -X strcat(dnbuf, "/"); -X strcat(dnbuf, sl); -X strcpy(dest, dnbuf); -X } -X#endif -X -X /* create output file */ -X if ((out = fopen(dest, "w")) == NULL) -X { -X fprintf(stderr, "ERROR: can't open output file %s\n", dest); -X exit(15); -X } -X#ifdef unix -X chmod(dest, mode); -X#endif -X -X decode(in, out, dest); -X -X if (fgets(buf, sizeof buf, in) == NULL || strncmp(buf,"end",3)) -X { /* don't be overly picky about newline ^ */ -X fprintf(stderr, "ERROR: no `end' line\n"); -X exit(16); -X } -X -X if (!(fgets(buf,sizeof buf,in) == NULL || strncmp(buf,"size ",3))) -X { -X sscanf(buf, "size %ld", &filesize); -X if (ftell(out) != filesize) -X { -X fprintf(stderr, "ERROR: file should have been %ld bytes long but was -X exit(17); -X } -X } -X through_loop = 1; -X} /* forever */ -X} /* main */ -X -X/* -X * Copy from in to out, decoding as you go. -X * If a return or newline is encountered too early in a line, it is -X * assumed that means that some editor has truncated trailing spaces. -X */ -Xdecode(in, out, dest) -XFILE *in; -XFILE *out; -Xchar *dest; -X{ -Xchar buf[81]; -Xchar *bp; -Xint nosum=0; -X#ifndef unix -Xextern errno; -X#endif -Xregister int j; -Xregister int n; -Xint checksum, line; -X -X for (line = 1; ; line++) /* for each input line */ -X { -X if (fgets(buf, sizeof buf, in) == NULL) -X { -X fprintf(stderr, "ERROR: input ended unexpectedly!\n"); -X exit(18); -X } -X -X /* Pad end of lines in case some editor truncated trailing -X spaces */ -X -X for (n=0;n<79;n++) /* search for first \r, \n or \000 */ -X { -X if (buf[n]=='\176') /* If BITNET made a twiddle, */ -X buf[n]='\136'; /* we make a caret */ -X if (buf[n]=='\r'||buf[n]=='\n'||buf[n]=='\000') -X break; -X } -X for (;n<79;n++) /* when found, fill rest of line with space */ -X { -X buf[n]=' '; -X } -X buf[79]=0; /* terminate new string */ -X -X checksum = 0; -X n = DEC(buf[0]); -X if (n <= 0) -X break; /* 0 bytes on a line?? Must be the last line */ -X -X bp = &buf[1]; -X -X /* FOUR input characters go into each THREE output charcters */ -X -X while (n >= 4) -X { -X j = DEC(bp[0]) << 2 | DEC(bp[1]) >> 4; putc(j, out); checksum += j; -X j = DEC(bp[1]) << 4 | DEC(bp[2]) >> 2; putc(j, out); checksum += j; -X j = DEC(bp[2]) << 6 | DEC(bp[3]); putc(j, out); checksum += j; -X checksum = checksum % SUMSIZE; -X bp += 4; -X n -= 3; -X } -X -X j = DEC(bp[0]) << 2 | DEC(bp[1]) >> 4; -X checksum += j; -X if (n >= 1) -X putc(j, out); -X j = DEC(bp[1]) << 4 | DEC(bp[2]) >> 2; -X checksum += j; -X if (n >= 2) -X putc(j, out); -X j = DEC(bp[2]) << 6 | DEC(bp[3]); -X checksum += j; -X if (n >= 3) -X putc(j, out); -X checksum = checksum % SUMSIZE; -X bp += 4; -X n -= 3; -X -X#ifndef unix -X /* Error checking under UNIX??? You must be kidding... */ -X /* Check if an error occured while writing to that last line */ -X if (errno) -X { -X fprintf(stderr, "ERROR: error writing to %s\n",dest); -X exit(19); -X } -X#endif -X -X /* The line has been decoded; now check that sum */ -X -X nosum |= !isspace(*bp); -X if (nosum) /* Is there a checksum at all?? */ -X { -X if (checksum != DEC(*bp)) /* Does that checksum match? */ -X { -X fprintf(stderr, "ERROR: checksum mismatch decoding %s, line %d.\ -X } -X } /* sum */ -X } /* line */ -X} /* function */ -X -X#ifdef unix -X/* -X * Return the ptr in sp at which the character c appears; -X * 0 if not found -X */ -Xchar * -Xindex(sp, c) -Xregister char *sp, c; -X{ -X do -X { -X if (*sp == c) -X return(sp); -X } -X while (*sp++); -X -X return(0); -X} -X#endif unix -X - -END_OF_FILE -echo shar: NEWLINE appended to \"'uudecode.c'\" -if test 6419 -ne `wc -c <'uudecode.c'`; then - echo shar: \"'uudecode.c'\" unpacked with wrong size! -fi -# end of 'uudecode.c' -fi -echo shar: End of shell archive. -exit 0 diff --git a/commands/flex-2.5.4/MISC/MVS/README b/commands/flex-2.5.4/MISC/MVS/README deleted file mode 100644 index 09741ab05..000000000 --- a/commands/flex-2.5.4/MISC/MVS/README +++ /dev/null @@ -1,44 +0,0 @@ -These patches and supplemental programs should allow porting to MVS or MVS/XA -in an EBCDIC envrionment, using SAS C V4.00C. - -Included are: - -rw-r--r-- 1 swl26 1573 Jul 17 14:32 README - -rw-rw-r-- 1 swl26 20861 Jul 17 13:41 diffs - -rw-rw-r-- 1 swl26 5022 Jul 17 14:00 fixit.l - -rw-rw-r-- 1 swl26 97644 Jul 17 13:42 initscan.mvs.c - -rw-rw-r-- 1 swl26 4898 Jul 17 14:08 unfixit.l - -The file "diffs" contains context diffs for changes to flex 2.3. - -The file "fixit.l" contains flex sources for a program to shorten external -variable and function names to 8 characters or less. This is required for the -"dumb" compiler linker used. - -The file "unfixit.l" reverses the changes in "fixit.l", to restore long names. -This is useful when trying to build diff files as created here. - -The file "initscan.mvs.c" is an already "flexed" version of scan.l, in an -EBCDIC environment. - -To install in an MVS environment, use patch to apply the diffs to flex 2.3, -then run "fixit" on all .c, .h, .l, .y, and .skel files. Move the files -to the MVS machine, and compile each of the .c files. (You will need a -"yacc" functional equivalent under MVS to expand parse.y in that -environment.) Link together, and the resulting flex should be ready to -go. To test, run the MVSflex -is8 -Ce on the scan.l, and you should get -back a file which is identical to initscan.mvs.c. - -Enjoy. - -Steven W. Layten -Senior Engineer -Chemical Abstracts Service -PO Box 3012 -2540 Olentangy River Road -Columbus, Ohio 43210 - -+1 614 421 3600 extension 3451 - -INET: swl26%cas.BITNET@CUNYVM.CUNY.Edu -UUCP: osu-cis!chemabs!swl26 -BITNET: swl26@cas.bitnet diff --git a/commands/flex-2.5.4/MISC/MVS/diffs b/commands/flex-2.5.4/MISC/MVS/diffs deleted file mode 100644 index 77cf305a8..000000000 --- a/commands/flex-2.5.4/MISC/MVS/diffs +++ /dev/null @@ -1,854 +0,0 @@ -diff -c ../Makefile ./Makefile -*** ../Makefile Thu Jun 28 00:44:07 1990 ---- ./Makefile Mon Jul 16 13:57:26 1990 -*************** -*** 39,49 **** - # AUXDIR, manual pages will be installed in MANDIR with extension MANEXT. - # Raw, unformatted troff source will be installed if INSTALLMAN=man, nroff - # preformatted versions will be installed if INSTALLMAN=cat. -! DESTDIR = - BINDIR = /usr/local - LIBDIR = /usr/local/lib - AUXDIR = /usr/local/lib - MANDIR = /usr/man/manl - MANEXT = l - INSTALLMAN = man - ---- 39,50 ---- - # AUXDIR, manual pages will be installed in MANDIR with extension MANEXT. - # Raw, unformatted troff source will be installed if INSTALLMAN=man, nroff - # preformatted versions will be installed if INSTALLMAN=cat. -! DESTDIR = /projects/m751stereo/code/c/swl26 - BINDIR = /usr/local - LIBDIR = /usr/local/lib - AUXDIR = /usr/local/lib - MANDIR = /usr/man/manl -+ INCLUDEDIR = . - MANEXT = l - INSTALLMAN = man - -*************** -*** 52,58 **** - - SKELETON_FILE = $(DESTDIR)$(AUXDIR)/flex.skel - SKELFLAGS = -DDEFAULT_SKELETON_FILE=\"$(SKELETON_FILE)\" -! CFLAGS = -O - LDFLAGS = -s - - COMPRESSION = ---- 53,59 ---- - - SKELETON_FILE = $(DESTDIR)$(AUXDIR)/flex.skel - SKELFLAGS = -DDEFAULT_SKELETON_FILE=\"$(SKELETON_FILE)\" -! CFLAGS = -O -DUSG -I$(INCLUDEDIR) - LDFLAGS = -s - - COMPRESSION = -diff -c ../ccl.c ./ccl.c -*** ../ccl.c Thu Jun 28 00:44:07 1990 ---- ./ccl.c Mon Jul 16 13:57:27 1990 -*************** -*** 28,37 **** - - #ifndef lint - static char rcsid[] = -! "@(#) $Header$ (LBL)"; - #endif - -! #include "flexdef.h" - - /* ccladd - add a single character to a ccl - * ---- 28,37 ---- - - #ifndef lint - static char rcsid[] = -! "@(#) $Header$ (LBL)"; - #endif - -! #include - - /* ccladd - add a single character to a ccl - * -diff -c ../dfa.c ./dfa.c -*** ../dfa.c Thu Jun 28 00:44:08 1990 ---- ./dfa.c Mon Jul 16 13:57:28 1990 -*************** -*** 28,37 **** - - #ifndef lint - static char rcsid[] = -! "@(#) $Header$ (LBL)"; - #endif - -! #include "flexdef.h" - - - /* declare functions that have forward references */ ---- 28,38 ---- - - #ifndef lint - static char rcsid[] = -! "@(#) $Header$ (LBL)"; - #endif - -! #include -! #include - - - /* declare functions that have forward references */ -*************** -*** 682,688 **** - register int j; - - for ( i = 'A', j = 'a'; i <= 'Z'; ++i, ++j ) -! state[i] = state[j]; - } - - if ( ds > num_start_states ) ---- 683,692 ---- - register int j; - - for ( i = 'A', j = 'a'; i <= 'Z'; ++i, ++j ) -! { -! if (isupper(i) ) -! state[i] = state[j]; -! } - } - - if ( ds > num_start_states ) -*************** -*** 958,964 **** - } - } - -! else if ( sym >= 'A' && sym <= 'Z' && caseins ) - flexfatal( "consistency check failed in symfollowset" ); - - else if ( sym == SYM_EPSILON ) ---- 962,968 ---- - } - } - -! else if ( isupper ( sym ) && caseins ) - flexfatal( "consistency check failed in symfollowset" ); - - else if ( sym == SYM_EPSILON ) -Only in .: diffs -Only in .: diffs.new -diff -c ../ecs.c ./ecs.c -*** ../ecs.c Thu Jun 28 00:44:08 1990 ---- ./ecs.c Mon Jul 16 13:57:28 1990 -*************** -*** 28,37 **** - - #ifndef lint - static char rcsid[] = -! "@(#) $Header$ (LBL)"; - #endif - -! #include "flexdef.h" - - /* ccl2ecl - convert character classes to set of equivalence classes - * ---- 28,37 ---- - - #ifndef lint - static char rcsid[] = -! "@(#) $Header$ (LBL)"; - #endif - -! #include - - /* ccl2ecl - convert character classes to set of equivalence classes - * -diff -c ../flex.skel ./flex.skel -*** ../flex.skel Thu Jun 28 00:44:27 1990 ---- ./flex.skel Mon Jul 16 13:57:29 1990 -*************** -*** 1,7 **** - /* A lexical scanner generated by flex */ - - /* scanner skeleton version: -! * $Header$ - */ - - #define FLEX_SCANNER ---- 1,7 ---- - /* A lexical scanner generated by flex */ - - /* scanner skeleton version: -! * $Header$ - */ - - #define FLEX_SCANNER -diff -c ../flexdef.h ./flexdef.h -*** ../flexdef.h Thu Jun 28 00:44:27 1990 ---- ./flexdef.h Mon Jul 16 13:57:30 1990 -*************** -*** 26,32 **** - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -! /* @(#) $Header$ (LBL) */ - - #ifndef FILE - #include ---- 26,32 ---- - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -! /* @(#) $Header$ (LBL) */ - - #ifndef FILE - #include -*************** -*** 45,51 **** - - /* size of input alphabet - should be size of ASCII set */ - #ifndef DEFAULT_CSIZE -! #define DEFAULT_CSIZE 128 - #endif - - #ifndef PROTO ---- 45,51 ---- - - /* size of input alphabet - should be size of ASCII set */ - #ifndef DEFAULT_CSIZE -! #define DEFAULT_CSIZE 256 - #endif - - #ifndef PROTO -*************** -*** 90,96 **** ---- 90,98 ---- - #define SHORT_FILE_NAMES - #endif - -+ #ifndef OSVS - char *malloc(), *realloc(); -+ #endif - - - /* maximum line length we'll have to deal with */ -*************** -*** 116,125 **** - #define true 1 - #define false 0 - -- - #ifndef DEFAULT_SKELETON_FILE - #define DEFAULT_SKELETON_FILE "flex.skel" -! #endif - - /* special chk[] values marking the slots taking by end-of-buffer and action - * numbers ---- 118,132 ---- - #define true 1 - #define false 0 - - #ifndef DEFAULT_SKELETON_FILE -+ #ifdef OSVS -+ #define DEFAULT_SKELETON_FILE "ctri01" -+ #define SYSUT1 "sysut1" -+ #define SYSUT2 "sysut2" -+ #else - #define DEFAULT_SKELETON_FILE "flex.skel" -! #endif /* OSVS */ -! #endif /* DEFAULT_SKELETON_FILE */ - - /* special chk[] values marking the slots taking by end-of-buffer and action - * numbers -*************** -*** 226,233 **** - #define INITIAL_MAX_SCS 40 /* maximum number of start conditions */ - #define MAX_SCS_INCREMENT 40 /* amount to bump by if it's not enough */ - -! #define ONE_STACK_SIZE 500 /* stack of states with only one out-transition */ -! #define SAME_TRANS -1 /* transition is the same as "default" entry for state */ - - /* the following percentages are used to tune table compression: - ---- 233,240 ---- - #define INITIAL_MAX_SCS 40 /* maximum number of start conditions */ - #define MAX_SCS_INCREMENT 40 /* amount to bump by if it's not enough */ - -! #define ONE_STACK_SIZE 500 /*stack of states with only one out-transition*/ -! #define SAME_TRANS -1 /*transition is the same as "default" entry for state */ - - /* the following percentages are used to tune table compression: - -diff -c ../gen.c ./gen.c -*** ../gen.c Thu Jun 28 00:44:28 1990 ---- ./gen.c Mon Jul 16 13:57:32 1990 -*************** -*** 28,37 **** - - #ifndef lint - static char rcsid[] = -! "@(#) $Header$ (LBL)"; - #endif - -! #include "flexdef.h" - - - /* declare functions that have forward references */ ---- 28,37 ---- - - #ifndef lint - static char rcsid[] = -! "@(#) $Header$ (LBL)"; - #endif - -! #include - - - /* declare functions that have forward references */ -*************** -*** 292,298 **** - - indent_puts( "{" ); - -! indent_puts( "if ( yy_lp && yy_lp < yy_accept[yy_current_state + 1] )" ); - indent_up(); - indent_puts( "{" ); - indent_puts( "yy_act = yy_acclist[yy_lp];" ); ---- 292,298 ---- - - indent_puts( "{" ); - -! indent_puts("if( yy_lp && yy_lp < yy_accept[yy_current_state + 1] )"); - indent_up(); - indent_puts( "{" ); - indent_puts( "yy_act = yy_acclist[yy_lp];" ); -diff -c ../initscan.c ./initscan.c -*** ../initscan.c Thu Jun 28 00:44:51 1990 ---- ./initscan.c Mon Jul 16 13:57:33 1990 -*************** -*** 1,7 **** - /* A lexical scanner generated by flex */ - - /* scanner skeleton version: -! * $Header$ - */ - - #define FLEX_SCANNER ---- 1,7 ---- - /* A lexical scanner generated by flex */ - - /* scanner skeleton version: -! * $Header$ - */ - - #define FLEX_SCANNER -*************** -*** 193,199 **** - - #ifndef lint - static char rcsid[] = -! "@(#) $Header$ (LBL)"; - #endif - - #undef yywrap ---- 193,199 ---- - - #ifndef lint - static char rcsid[] = -! "@(#) $Header$ (LBL)"; - #endif - - #undef yywrap -diff -c ../libmain.c ./libmain.c -*** ../libmain.c Thu Jun 28 00:44:28 1990 ---- ./libmain.c Mon Jul 16 13:57:34 1990 -*************** -*** 1,6 **** - /* libmain - flex run-time support library "main" function */ - -! /* $Header$ */ - - extern int yylex(); - ---- 1,6 ---- - /* libmain - flex run-time support library "main" function */ - -! /* $Header$ */ - - extern int yylex(); - -diff -c ../main.c ./main.c -*** ../main.c Thu Jun 28 00:44:29 1990 ---- ./main.c Mon Jul 16 13:57:34 1990 -*************** -*** 34,44 **** - - #ifndef lint - static char rcsid[] = -! "@(#) $Header$ (LBL)"; - #endif - - -! #include "flexdef.h" - - static char flex_version[] = "2.3"; - ---- 34,44 ---- - - #ifndef lint - static char rcsid[] = -! "@(#) $Header$ (LBL)"; - #endif - - -! #include - - static char flex_version[] = "2.3"; - -*************** -*** 97,106 **** - char *program_name; - - #ifndef SHORT_FILE_NAMES - static char *outfile = "lex.yy.c"; -! #else - static char *outfile = "lexyy.c"; -! #endif - static int outfile_created = 0; - static int use_stdout; - static char *skelname = NULL; ---- 97,110 ---- - char *program_name; - - #ifndef SHORT_FILE_NAMES -+ #ifdef OSVS -+ static char *outfile = "ctro01"; -+ #else /* not OSVS */ - static char *outfile = "lex.yy.c"; -! #endif /* not OSVS */ -! #else /* SHORT_FILE_NAMES */ - static char *outfile = "lexyy.c"; -! #endif /* SHORT_FILE_NAMES */ - static int outfile_created = 0; - static int use_stdout; - static char *skelname = NULL; -*************** -*** 209,216 **** ---- 213,222 ---- - else if ( fclose( temp_action_file ) ) - flexfatal( "error occurred when closing temporary action file" ); - -+ #ifndef OSVS - else if ( unlink( action_file_name ) ) - flexfatal( "error occurred when deleting temporary action file" ); -+ #endif - } - - if ( status != 0 && outfile_created ) -*************** -*** 221,228 **** ---- 227,236 ---- - else if ( fclose( stdout ) ) - flexfatal( "error occurred when closing output file" ); - -+ #ifndef OSVS - else if ( unlink( outfile ) ) - flexfatal( "error occurred when deleting output file" ); -+ #endif - } - - if ( backtrack_report && backtrack_file ) -*************** -*** 574,583 **** - if ( backtrack_report ) - { - #ifndef SHORT_FILE_NAMES - backtrack_file = fopen( "lex.backtrack", "w" ); -! #else - backtrack_file = fopen( "lex.bck", "w" ); -! #endif - - if ( backtrack_file == NULL ) - flexerror( "could not create lex.backtrack" ); ---- 582,595 ---- - if ( backtrack_report ) - { - #ifndef SHORT_FILE_NAMES -+ #ifdef OSVS -+ backtrack_file = fopen( SYSUT2, "w"); -+ #else /* not OSVS */ - backtrack_file = fopen( "lex.backtrack", "w" ); -! #endif /* OSVS */ -! #else /* SHORT_FILE_NAMES */ - backtrack_file = fopen( "lex.bck", "w" ); -! #endif /* SHORT_FILE_NAMES */ - - if ( backtrack_file == NULL ) - flexerror( "could not create lex.backtrack" ); -*************** -*** 597,604 **** - lerrsf( "can't open skeleton file %s", skelname ); - - #ifdef SYS_V - action_file_name = tmpnam( NULL ); -! #endif - - if ( action_file_name == NULL ) - { ---- 609,620 ---- - lerrsf( "can't open skeleton file %s", skelname ); - - #ifdef SYS_V -+ #ifndef OSVS - action_file_name = tmpnam( NULL ); -! #else /* OSVS */ -! action_file_name = SYSUT1; -! #endif /* OSVS */ -! #endif /* SYS_V */ - - if ( action_file_name == NULL ) - { -*************** -*** 609,615 **** ---- 625,636 ---- - #else - (void) strcpy( temp_action_file_name, "flexXXXXXX.tmp" ); - #endif -+ #ifndef OSVS - (void) mktemp( temp_action_file_name ); -+ #else /* OSVS */ -+ /* should never be executed in OSVS as IF should always be false */ -+ (void) strcpy( temp_action_file_name, SYSUT1 ) ; -+ #endif /* OSVS */ - - action_file_name = temp_action_file_name; - } -diff -c ../misc.c ./misc.c -*** ../misc.c Thu Jun 28 00:44:40 1990 ---- ./misc.c Mon Jul 16 13:57:35 1990 -*************** -*** 28,38 **** - - #ifndef lint - static char rcsid[] = -! "@(#) $Header$ (LBL)"; - #endif - - #include -! #include "flexdef.h" - - - /* ANSI C does not guarantee that isascii() is defined */ ---- 28,38 ---- - - #ifndef lint - static char rcsid[] = -! "@(#) $Header$ (LBL)"; - #endif - - #include -! #include - - - /* ANSI C does not guarantee that isascii() is defined */ -*************** -*** 107,113 **** ---- 107,117 ---- - { - while ( *str ) - { -+ #ifdef OSVS -+ if ( ! islower( *str ) ) -+ #else - if ( ! isascii( *str ) || ! islower( *str ) ) -+ #endif - return ( 0 ); - ++str; - } -*************** -*** 130,136 **** ---- 134,144 ---- - { - while ( *str ) - { -+ #ifdef OSVS -+ if ( ! isupper( (char) *str ) ) -+ #else - if ( ! isascii( *str ) || ! isupper( (char) *str ) ) -+ #endif - return ( 0 ); - ++str; - } -*************** -*** 182,188 **** ---- 190,200 ---- - register int c; - - { -+ #ifdef OSVS -+ return ( isupper( c ) ? (Char) tolower( c ) : (Char) c ); -+ #else - return ( (isascii( c ) && isupper( c )) ? tolower( c ) : c ); -+ #endif - } - - -*************** -*** 204,210 **** - for ( c = str; *c; ++c ) - ; - -! copy = malloc( (unsigned) ((c - str + 1) * sizeof( char )) ); - - if ( copy == NULL ) - flexfatal( "dynamic memory failure in copy_string()" ); ---- 216,222 ---- - for ( c = str; *c; ++c ) - ; - -! copy = (char *) malloc( (unsigned) ((c - str + 1) * sizeof( char )) ); - - if ( copy == NULL ) - flexfatal( "dynamic memory failure in copy_string()" ); -*************** -*** 392,403 **** ---- 404,421 ---- - - #ifndef MS_DOS - #ifndef VMS -+ #ifndef OSVS - #include -+ #endif /* OSVS */ - #else - #include - #endif - #endif - -+ #ifdef OSVS -+ #include -+ #endif /* OSVS */ -+ - #ifdef MS_DOS - #include - typedef long time_t; -*************** -*** 615,621 **** ---- 633,643 ---- - if ( array[1] == 'x' ) - ++sptr; - -+ #ifdef OSVS -+ while ( isdigit( array[sptr] ) ) -+ #else - while ( isascii( array[sptr] ) && isdigit( array[sptr] ) ) -+ #endif - /* don't increment inside loop control because if - * isdigit() is a macro it will expand it to two - * increments ... -Only in ..: new -diff -c ../nfa.c ./nfa.c -*** ../nfa.c Thu Jun 28 00:44:40 1990 ---- ./nfa.c Mon Jul 16 13:57:36 1990 -*************** -*** 28,37 **** - - #ifndef lint - static char rcsid[] = -! "@(#) $Header$ (LBL)"; - #endif - -! #include "flexdef.h" - - - /* declare functions that have forward references */ ---- 28,37 ---- - - #ifndef lint - static char rcsid[] = -! "@(#) $Header$ (LBL)"; - #endif - -! #include - - - /* declare functions that have forward references */ -*************** -*** 110,116 **** - { - int sym, tsp1, tsp2, anum, ns; - -! fprintf( stderr, "\n\n********** beginning dump of nfa with start state %d\n", - state1 ); - - /* we probably should loop starting at firstst[state1] and going to ---- 110,116 ---- - { - int sym, tsp1, tsp2, anum, ns; - -! fprintf(stderr,"\n\n********* beginning dump of nfa with start state %d\n", - state1 ); - - /* we probably should loop starting at firstst[state1] and going to -diff -c ../parse.y ./parse.y -*** ../parse.y Thu Jun 28 00:44:40 1990 ---- ./parse.y Mon Jul 16 13:57:36 1990 -*************** -*** 32,45 **** - - #ifndef lint - static char rcsid[] = -! "@(#) $Header$ (LBL)"; - #endif - -! #include "flexdef.h" - - int pat, scnum, eps, headcnt, trailcnt, anyccl, lastchar, i, actvp, rulelen; - int trlcontxt, xcluflg, cclsorted, varlength, variable_trail_rule; - Char clower(); - - static int madeany = false; /* whether we've made the '.' character class */ - int previous_continued_action; /* whether the previous rule's action was '|' */ ---- 32,47 ---- - - #ifndef lint - static char rcsid[] = -! "@(#) $Header$ (LBL)"; - #endif - -! #include - - int pat, scnum, eps, headcnt, trailcnt, anyccl, lastchar, i, actvp, rulelen; - int trlcontxt, xcluflg, cclsorted, varlength, variable_trail_rule; - Char clower(); -+ void build_eof_action(); -+ void yyerror(); - - static int madeany = false; /* whether we've made the '.' character class */ - int previous_continued_action; /* whether the previous rule's action was '|' */ -diff -c ../scan.l ./scan.l -*** ../scan.l Thu Jun 28 00:44:41 1990 ---- ./scan.l Mon Jul 16 13:57:37 1990 -*************** -*** 30,42 **** - - #ifndef lint - static char rcsid[] = -! "@(#) $Header$ (LBL)"; - #endif - - #undef yywrap - -! #include "flexdef.h" -! #include "parse.h" - - #define ACTION_ECHO fprintf( temp_action_file, "%s", yytext ) - #define MARK_END_OF_PROLOG fprintf( temp_action_file, "%%%% end of prolog\n" ); ---- 30,42 ---- - - #ifndef lint - static char rcsid[] = -! "@(#) $Header$ (LBL)"; - #endif - - #undef yywrap - -! #include -! #include - - #define ACTION_ECHO fprintf( temp_action_file, "%s", yytext ) - #define MARK_END_OF_PROLOG fprintf( temp_action_file, "%%%% end of prolog\n" ); -diff -c ../sym.c ./sym.c -*** ../sym.c Thu Jun 28 00:44:41 1990 ---- ./sym.c Mon Jul 16 13:57:37 1990 -*************** -*** 28,37 **** - - #ifndef lint - static char rcsid[] = -! "@(#) $Header$ (LBL)"; - #endif - -! #include "flexdef.h" - - - /* declare functions that have forward references */ ---- 28,37 ---- - - #ifndef lint - static char rcsid[] = -! "@(#) $Header$ (LBL)"; - #endif - -! #include - - - /* declare functions that have forward references */ -diff -c ../tblcmp.c ./tblcmp.c -*** ../tblcmp.c Thu Jun 28 00:44:41 1990 ---- ./tblcmp.c Mon Jul 16 13:57:38 1990 -*************** -*** 28,37 **** - - #ifndef lint - static char rcsid[] = -! "@(#) $Header$ (LBL)"; - #endif - -! #include "flexdef.h" - - - /* declarations for functions that have forward references */ ---- 28,37 ---- - - #ifndef lint - static char rcsid[] = -! "@(#) $Header$ (LBL)"; - #endif - -! #include - - - /* declarations for functions that have forward references */ -diff -c ../yylex.c ./yylex.c -*** ../yylex.c Thu Jun 28 00:44:41 1990 ---- ./yylex.c Mon Jul 16 13:57:38 1990 -*************** -*** 28,39 **** - - #ifndef lint - static char rcsid[] = -! "@(#) $Header$ (LBL)"; - #endif - - #include -! #include "flexdef.h" -! #include "parse.h" - - - /* ANSI C does not guarantee that isascii() is defined */ ---- 28,39 ---- - - #ifndef lint - static char rcsid[] = -! "@(#) $Header$ (LBL)"; - #endif - - #include -! #include -! #include - - - /* ANSI C does not guarantee that isascii() is defined */ -*************** -*** 180,186 **** ---- 180,190 ---- - break; - - default: -+ #ifdef OSVS -+ if ( ! isprint( yylval ) ) -+ #else - if ( ! isascii( yylval ) || ! isprint( yylval ) ) -+ #endif - fprintf( stderr, "\\%.3o", yylval ); - else - (void) putc( yylval, stderr ); diff --git a/commands/flex-2.5.4/MISC/MVS/fixit.l b/commands/flex-2.5.4/MISC/MVS/fixit.l deleted file mode 100644 index 3e15b6fa4..000000000 --- a/commands/flex-2.5.4/MISC/MVS/fixit.l +++ /dev/null @@ -1,138 +0,0 @@ -%{ -/* fixit.l - convert long external names to names of 8-bytes or less */ -/* - * This program is included to satisfy "dumb" compilers/linkers which - * do not know about externals of names longer than 8 bytes. - * - * Steven W. Layten - * Chemical Abstracts Service - * PO BOX 3012 - * Columbus, OH 43210 - */ -%} -%% -"action_file_name" printf("actfilnm"); -"action_out" printf("actnout"); -"add_accept" printf("addacpt"); -"all_lower" printf("alllower"); -"all_upper" printf("allupper"); -"allocate_array" printf("allocarr"); -"assoc_rule" printf("asscrule"); -"backtrack_file" printf("bktrkfil"); -"backtrack_report" printf("bktrkrep"); -"bol_needed" printf("bol_nded"); -"build_eof_action" printf("bldeofac"); -"cclinstal" printf("cclnstal"); -"ccllookup" printf("ccllookp"); -"cclnegate" printf("cclnegat"); -"cclsorted" printf("cclsrted"); -"check_for_backtracking" printf("ck4bktrk"); -"check_trailing_context" printf("cktrlcnt"); -"continued_action" printf("cntdactn"); -"copy_string" printf("copystrn"); -"copy_unsigned_string" printf("cpunsstr"); -"copyright" printf("cpyrght"); -"copysingl" printf("copysngl"); -"current_max_ccl_tbl_size" printf("c_mx_ccl"); -"current_max_dfa_size" printf("c_mx_dfa"); -"current_max_dfas" printf("c_mxdfas"); -"current_max_rules" printf("curmxrls"); -"current_max_scs" printf("c_mx_scs"); -"current_max_template_xpairs" printf("c_mx_tmp"); -"current_max_xpairs" printf("c_mx_xpr"); -"current_maxccls" printf("c_mxccls"); -"current_mns" printf("curr_mns"); -"current_state_type" printf("cursttyp"); -"dataflush" printf("datflush"); -"dfaacc_union" printf("dfacunin"); -"do_indent" printf("do_indnt"); -"dump_associated_rules" printf("dmpasrl"); -"dump_transitions" printf("dmptrns"); -"dupmachine" printf("dupmach"); -"ecs_from_xlation" printf("ecsfrmxt"); -"end_of_buffer_state" printf("eobstate"); -"epsclosure" printf("epsclos"); -"expand_nxt_chk" printf("expnxtck"); -"find_table_space" printf("fndtblsp"); -"finish_rule" printf("fnshrule"); -"firstfree" printf("firstfre"); -"firstprot" printf("firstprt"); -"flex_gettime" printf("flxgettm"); -"flexerror" printf("flxerror"); -"flexfatal" printf("flxfatal"); -"format_pinpoint_message" printf("fmtptmsg"); -"gen_NUL_trans" printf("gnNULtrn"); -"gen_backtracking" printf("gnbktrkg"); -"gen_bt_action" printf("gnbtactn"); -"gen_find_action" printf("gnfndact"); -"gen_line_dirs" printf("gnlindir"); -"gen_next_compressed_state" printf("gnnxcste"); -"gen_next_match" printf("gnnxmtch"); -"gen_next_state" printf("gnnxtst"); -"gen_start_state" printf("gnstrtst"); -"hash_entry" printf("hshentry"); -"hashfunct" printf("hshfct"); -"increase_max_dfas" printf("incmxdfa"); -"indent_put2s" printf("indput2s"); -"indent_puts" printf("indputs"); -"infilename" printf("infilnam"); -"input_files" printf("inp_fles"); -"interactive" printf("intractv"); -"line_directive_out" printf("lndirout"); -"link_machines" printf("lnkmchns"); -"list_character_set" printf("lst_cset"); -"make_tables" printf("maketbls"); -"mark_beginning_as_normal" printf("mkbgnorm"); -"mktemplate" printf("mktmplat"); -"num_backtracking" printf("nbktrckg"); -"num_input_files" printf("ninfiles"); -"num_reallocs" printf("numraloc"); -"num_rules" printf("numrules"); -"num_xlations" printf("nuxlatns"); -"numsnpairs" printf("numnpair"); -"output_file_name" printf("outfilnm"); -"peakpairs" printf("peakpair"); -"performance_report" printf("perf_rep"); -"pinpoint_message" printf("pptmsg"); -"place_state" printf("plcstate"); -"previous_continued_action" printf("prvctdan"); -"printstats" printf("prtstats"); -"program_name" printf("pgm_name"); -"protcomst" printf("prtcomst"); -"readable_form" printf("rdblefrm"); -"real_reject" printf("realrjct"); -"reallocate_array" printf("rallocar"); -"reject_really_used" printf("rjctused"); -"rule_linenum" printf("rulelnno"); -"rule_type" printf("ruletype"); -"set_input_file" printf("stinpfle"); -"set_up_initial_allocations" printf("setupia"); -"starttime" printf("startime"); -"state_type" printf("ste_type"); -"symfollowset" printf("symfollo"); -"sympartition" printf("sympartn"); -"syntaxerror" printf("syntxerr"); -"temp_action_file" printf("tmpactfl"); -"todo_head" printf("todohead"); -"todo_next" printf("todonext"); -"transchar" printf("trnschar"); -"transition_struct_out" printf("trnstout"); -"trlcontxt" printf("trlcntxt"); -"variable_trail_rule" printf("vtrailrl"); -"variable_trailing_context_rules" printf("vtrlctrl"); -"varlength" printf("varlngth"); -"yy_create_buffer" printf("yycrbffr"); -"yy_delete_buffer" printf("yydlbffr"); -"yy_init_buffer" printf("yyinbffr"); -"yy_load_buffer_state" printf("yyldbfst"); -"yy_switch_to_buffer" printf("yyswtobf"); -"yyerrflag" printf("yyerrflg"); -"yymore_really_used" printf("yymrreus"); -"yymore_used" printf("yymrused"); -"yyrestart" printf("yyrestrt"); -. ECHO; -%% -main() -{ - yylex(); -} diff --git a/commands/flex-2.5.4/MISC/MVS/initscan-mvs.c b/commands/flex-2.5.4/MISC/MVS/initscan-mvs.c deleted file mode 100644 index 9aaed4a53..000000000 --- a/commands/flex-2.5.4/MISC/MVS/initscan-mvs.c +++ /dev/null @@ -1,2672 +0,0 @@ -/* A lexical scanner generated by flex */ - -/* scanner skeleton version: - * $Header: flex.skel,v 2.13 90/05/26 17:24:13 ve - */ - -#define FLEX_SCANNER - -#include - -#ifdef __STDC__ - -#ifndef DONT_HAVE_STDLIB_H -#include -#else -void *malloc( unsigned ); -void free( void* ); -#endif - -#define YY_USE_PROTOS -#define YY_USE_CONST -#endif - - -/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ -#ifdef c_plusplus -#ifndef __cplusplus -#define __cplusplus -#endif -#endif - - -#ifdef __cplusplus - -#ifndef __STDC__ -#include -#endif - -#include - -/* use prototypes in function declarations */ -#define YY_USE_PROTOS - -/* the "const" storage-class-modifier is valid */ -#define YY_USE_CONST - -#endif - - -#ifdef __TURBOC__ -#define YY_USE_CONST -#endif - - -#ifndef YY_USE_CONST -#define const -#endif - - -#ifdef YY_USE_PROTOS -#define YY_PROTO(proto) proto -#else -#define YY_PROTO(proto) () -/* there's no standard place to get these definitions */ -char *malloc(); -int free(); -int read(); -#endif - - -/* amount of stuff to slurp up with each read */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* returned upon end-of-file */ -#define YY_END_TOK 0 - -/* copy whatever the last rule matched to the standard output */ - -/* cast to (char *) is because for 8-bit chars, yytext is (unsigned char *) */ -/* this used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite() - */ -#define ECHO (void) fwrite( (char *) yytext, yyleng, 1, yyout ) - -/* gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#define YY_INPUT(buf,result,max_size) \ - if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \ - YY_FATAL_ERROR( "read() in flex scanner failed" ); -#define YY_NULL 0 - -/* no semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#define yyterminate() return ( YY_NULL ) - -/* report a fatal error */ - -/* The funky do-while is used to turn this macro definition into - * a single C statement (which needs a semi-colon terminator). - * This avoids problems with code like: - * - * if ( something_happens ) - * YY_FATAL_ERROR( "oops, the something happened" ); - * else - * everything_okay(); - * - * Prior to using the do-while the compiler would get upset at the - * "else" because it interpreted the "if" statement as being all - * done when it reached the ';' after the YY_FATAL_ERROR() call. - */ - -#define YY_FATAL_ERROR(msg) \ - do \ - { \ - (void) fputs( msg, stderr ); \ - (void) putc( '\n', stderr ); \ - exit( 1 ); \ - } \ - while ( 0 ) - -/* default yywrap function - always treat EOF as an EOF */ -#define yywrap() 1 - -/* enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN - */ -#define BEGIN yy_start = 1 + 2 * - -/* action number for EOF rule of a given start state */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* special action meaning "start processing a new file" */ -#define YY_NEW_FILE \ - do \ - { \ - yyinbffr( yy_current_buffer, yyin ); \ - yyldbfst(); \ - } \ - while ( 0 ) - -/* default declaration of generated scanner - a define so the user can - * easily add parameters - */ -#define YY_DECL int yylex YY_PROTO(( void )) - -/* code executed at the end of each rule */ -#define YY_BREAK break; - -#define YY_END_OF_BUFFER_CHAR 0 - -#ifndef YY_BUF_SIZE -#define YY_BUF_SIZE (YY_READ_BUF_SIZE * 2) /* size of default input buffer */ -#endif - -typedef struct yy_buffer_state *YY_BUFFER_STATE; - -#define YY_CHAR unsigned char -# line 1 "" -#define INITIAL 0 -/* scan.l - scanner for flex input */ -# line 5 "" -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Vern Paxson. - * - * The United States Government has rights in this work pursuant - * to contract no. DE-AC03-76SF00098 between the United States - * Department of Energy and the University of California. - * - * Redistribution and use in source and binary forms with or without - * modification are permitted provided that: (1) source distributions retain - * this entire copyright notice and comment, and (2) distributions including - * binaries display the following acknowledgement: ``This product includes - * software developed by the University of California, Berkeley and its - * contributors'' in the documentation or other materials provided with the - * distribution and in all advertising materials mentioning features or use - * of this software. Neither the name of the University nor the names of - * its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#ifndef lint -static char rcsid[] = - "@(#) $Header$ (LBL)"; -#endif - -#undef yywrap - -#include -#include - -#define ACTION_ECHO fprintf( tmpactfl, "%s", yytext ) -#define MARK_END_OF_PROLOG fprintf( tmpactfl, "%%%% end of prolog\n" ); - -#undef YY_DECL -#define YY_DECL \ - int flexscan() - -#define RETURNCHAR \ - yylval = yytext[0]; \ - return ( CHAR ); - -#define RETURNNAME \ - (void) strcpy( nmstr, (char *) yytext ); \ - return ( NAME ); - -#define PUT_BACK_STRING(str, start) \ - for ( i = strlen( (char *) (str) ) - 1; i >= start; --i ) \ - unput((str)[i]) - -#define CHECK_REJECT(str) \ - if ( allupper( str ) ) \ - reject = true; - -#define CHECK_YYMORE(str) \ - if ( alllower( str ) ) \ - yymrused = true; -#define SECT2 1 -#define SECT2PROLOG 2 -#define SECT3 3 -#define CODEBLOCK 4 -#define PICKUPDEF 5 -#define SC 6 -#define CARETISBOL 7 -#define NUM 8 -#define QUOTE 9 -#define FIRSTCCL 10 -#define CCL 11 -#define ACTION 12 -#define RECOVER 13 -#define BRACEERROR 14 -#define C_COMMENT 15 -#define ACTION_COMMENT 16 -#define ACTION_STRING 17 -#define PERCENT_BRACE_ACTION 18 -#define USED_LIST 19 -#define CODEBLOCK_2 20 -#define XLATION 21 -# line 84 "" - -/* done after the current pattern has been matched and before the - * corresponding action - sets up yytext - */ -#define YY_DO_BEFORE_ACTION \ - yytext = yy_bp; \ - yyleng = yy_cp - yy_bp; \ - yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yy_c_buf_p = yy_cp; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - -/* return all but the first 'n' matched characters back to the input stream */ -#define yyless(n) \ - do \ - { \ - /* undo effects of setting up yytext */ \ - *yy_cp = yy_hold_char; \ - yy_c_buf_p = yy_cp = yy_bp + n; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, yytext ) - - -struct yy_buffer_state - { - FILE *yy_input_file; - - YY_CHAR *yy_ch_buf; /* input buffer */ - YY_CHAR *yy_buf_pos; /* current position in input buffer */ - - /* size of input buffer in bytes, not including room for EOB characters*/ - int yy_buf_size; - - /* number of characters read into yy_ch_buf, not including EOB characters */ - int yy_n_chars; - - int yy_eof_status; /* whether we've seen an EOF on this buffer */ -#define EOF_NOT_SEEN 0 - /* "pending" happens when the EOF has been seen but there's still - * some text process - */ -#define EOF_PENDING 1 -#define EOF_DONE 2 - }; - -static YY_BUFFER_STATE yy_current_buffer; - -/* we provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state" - */ -#define YY_CURRENT_BUFFER yy_current_buffer - - -/* yy_hold_char holds the character lost when yytext is formed */ -static YY_CHAR yy_hold_char; - -static int yy_n_chars; /* number of characters read into yy_ch_buf */ - - - -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -#ifndef YY_USER_INIT -#define YY_USER_INIT -#endif - -extern YY_CHAR *yytext; -extern int yyleng; -extern FILE *yyin, *yyout; - -YY_CHAR *yytext; -int yyleng; - -FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; - -#define YY_END_OF_BUFFER 121 -typedef int yy_ste_type; -static const short int yy_accept[341] = - { 0, - 0, 0, 0, 0, 0, 0, 119, 119, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 121, 19, 7, 18, 19, 16, - 1, 17, 19, 19, 15, 19, 67, 59, 60, 66, - 51, 67, 53, 67, 67, 67, 50, 49, 52, 67, - 120, 47, 119, 119, 28, 29, 28, 28, 28, 28, - 31, 30, 32, 73, 120, 69, 72, 70, 74, 88, - 89, 86, 87, 85, 75, 77, 76, 75, 81, 81, - - 80, 81, 83, 83, 84, 83, 99, 104, 105, 100, - 105, 103, 100, 100, 97, 98, 120, 33, 91, 90, - 22, 24, 23, 107, 109, 108, 111, 113, 114, 115, - 95, 95, 96, 95, 95, 95, 95, 38, 35, 34, - 38, 38, 44, 42, 45, 44, 44, 41, 41, 41, - 41, 40, 7, 18, 0, 16, 1, 17, 3, 14, - 8, 0, 12, 4, 0, 0, 5, 0, 15, 0, - 2, 59, 60, 0, 0, 0, 56, 0, 0, 55, - 55, 54, 117, 117, 117, 50, 49, 63, 50, 0, - 47, 46, 119, 119, 28, 28, 28, 28, 28, 31, - - 30, 72, 71, 85, 78, 79, 118, 118, 118, 82, - 99, 101, 100, 0, 102, 0, 100, 100, 0, 33, - 22, 20, 107, 106, 111, 112, 95, 95, 95, 92, - 95, 95, 95, 38, 35, 38, 38, 42, 0, 43, - 43, 43, 42, 40, 0, 13, 14, 8, 8, 0, - 12, 4, 0, 0, 0, 5, 0, 6, 0, 58, - 57, 0, 64, 0, 0, 55, 55, 65, 117, 117, - 63, 28, 28, 28, 25, 0, 118, 118, 100, 100, - 0, 21, 92, 92, 95, 95, 38, 38, 0, 39, - 43, 43, 0, 11, 4, 0, 11, 0, 0, 5, - - 0, 0, 0, 117, 28, 28, 118, 100, 100, 95, - 95, 38, 38, 43, 0, 9, 0, 0, 0, 28, - 28, 100, 100, 95, 95, 38, 38, 0, 0, 26, - 27, 93, 94, 93, 94, 36, 37, 10, 62, 0 - } ; - -static const YY_CHAR yy_ec[256] = - { 0, - 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, - 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, - 4, 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, 5, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 6, 7, 6, 6, 8, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 9, 10, 6, 1, 11, 12, 13, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 14, 15, 16, 17, - 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 18, 1, 19, 1, 20, 1, 21, 22, - 23, 24, 25, 26, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 27, 28, 16, 29, 30, 31, - 28, 16, 32, 16, 16, 16, 16, 16, 16, 16, - 16, 33, 34, 35, 16, 16, 36, 37, 16, 1, - 1, 1, 38, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 39, 1, - 1, 40, 21, 22, 23, 24, 25, 26, 16, 16, - - 16, 1, 1, 1, 1, 1, 1, 41, 27, 28, - 16, 29, 30, 31, 28, 16, 32, 1, 1, 1, - 1, 1, 1, 42, 1, 33, 34, 35, 16, 16, - 36, 37, 16, 1, 1, 1, 1, 1, 1, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 1, - 1, 1, 1, 1, 1 - } ; - -static const short int yy_base[404] = - { 0, - 0, 43, 85, 126, 1573, 1572, 1571, 1570, 168, 1558, - 97, 104, 211, 0, 1544, 1543, 99, 106, 118, 251, - 252, 254, 112, 114, 296, 0, 1549, 1548, 107, 111, - 140, 151, 153, 155, 253, 336, 378, 0, 339, 420, - 0, 0, 424, 465, 1550, 3243, 257, 3243, 1515, 0, - 265, 3243, 1538, 494, 0, 1540, 3243, 272, 3243, 3243, - 1495, 277, 3243, 1459, 534, 61, 343, 3243, 3243, 81, - 1496, 0, 1495, 3243, 0, 3243, 0, 1473, 1443, 1438, - 0, 281, 3243, 3243, 3243, 3243, 0, 1467, 3243, 3243, - 3243, 3243, 3243, 1434, 3243, 3243, 3243, 76, 3243, 1463, - - 3243, 242, 3243, 0, 3243, 314, 0, 3243, 1464, 0, - 330, 3243, 1448, 745, 3243, 3243, 777, 3243, 3243, 3243, - 0, 3243, 767, 0, 3243, 766, 0, 3243, 3243, 0, - 0, 350, 3243, 737, 0, 752, 739, 0, 286, 3243, - 750, 737, 3243, 357, 3243, 739, 318, 3243, 428, 738, - 327, 728, 364, 3243, 432, 0, 438, 3243, 3243, 372, - 442, 765, 446, 0, 451, 84, 0, 765, 0, 764, - 3243, 457, 3243, 763, 718, 732, 3243, 434, 438, 0, - 566, 3243, 3243, 0, 712, 480, 3243, 0, 3243, 750, - 0, 3243, 749, 3243, 0, 0, 725, 722, 609, 0, - - 484, 0, 3243, 707, 3243, 3243, 3243, 0, 706, 3243, - 0, 3243, 0, 456, 3243, 0, 721, 718, 742, 3243, - 0, 741, 0, 3243, 0, 3243, 0, 488, 703, 652, - 0, 709, 706, 0, 494, 707, 704, 499, 508, 3243, - 0, 689, 694, 688, 581, 3243, 518, 0, 603, 725, - 698, 0, 702, 693, 697, 0, 706, 3243, 705, 3243, - 3243, 671, 3243, 717, 669, 0, 0, 3243, 0, 655, - 0, 631, 573, 0, 3243, 577, 0, 537, 554, 507, - 529, 3243, 0, 0, 507, 500, 493, 485, 711, 3243, - 0, 471, 502, 3243, 0, 715, 3243, 472, 476, 0, - - 468, 740, 682, 3243, 469, 447, 3243, 455, 432, 440, - 426, 427, 414, 3243, 413, 3243, 415, 684, 688, 339, - 339, 258, 265, 238, 142, 128, 133, 121, 126, 0, - 0, 0, 0, 0, 0, 0, 0, 3243, 3243, 3243, - 783, 826, 869, 912, 955, 998, 1041, 1084, 1127, 1170, - 1213, 1256, 1299, 1342, 1385, 1428, 1460, 1503, 1535, 1578, - 1621, 1664, 1707, 1750, 1793, 1836, 1868, 1911, 1943, 1986, - 2029, 2072, 2115, 2147, 2190, 2233, 2276, 2319, 2362, 2405, - 2448, 2480, 2523, 2566, 2609, 2637, 2659, 2696, 2739, 2782, - 2805, 2848, 2871, 2914, 2937, 2980, 3012, 3044, 3067, 3110, - - 3133, 3176, 3199 - } ; - -static const short int yy_def[404] = - { 0, - 340, 340, 341, 341, 342, 342, 343, 343, 340, 9, - 344, 344, 340, 13, 345, 345, 346, 346, 347, 347, - 348, 348, 349, 349, 340, 25, 350, 350, 345, 345, - 351, 351, 352, 352, 353, 353, 340, 37, 354, 354, - 37, 37, 355, 356, 340, 340, 340, 340, 340, 357, - 340, 340, 340, 358, 359, 360, 340, 340, 340, 340, - 340, 340, 340, 361, 340, 362, 340, 340, 340, 340, - 363, 364, 365, 340, 366, 340, 367, 367, 367, 366, - 368, 340, 340, 340, 340, 340, 369, 340, 340, 340, - 340, 340, 340, 340, 340, 340, 340, 362, 340, 370, - - 340, 371, 340, 372, 340, 362, 373, 340, 340, 374, - 375, 340, 374, 374, 340, 340, 376, 340, 340, 340, - 377, 340, 340, 378, 340, 340, 379, 340, 340, 380, - 381, 381, 340, 381, 382, 382, 382, 383, 340, 340, - 383, 383, 340, 340, 340, 340, 384, 340, 340, 340, - 384, 340, 340, 340, 340, 357, 340, 340, 340, 340, - 385, 340, 340, 386, 340, 340, 387, 388, 359, 360, - 340, 340, 340, 389, 340, 340, 340, 361, 361, 390, - 390, 340, 340, 391, 340, 340, 340, 392, 340, 363, - 364, 340, 365, 340, 366, 367, 367, 367, 340, 368, - - 340, 369, 340, 340, 340, 340, 340, 393, 340, 340, - 373, 340, 374, 375, 340, 375, 374, 374, 376, 340, - 377, 394, 378, 340, 379, 340, 381, 381, 381, 340, - 382, 382, 382, 383, 340, 383, 383, 340, 340, 340, - 395, 340, 340, 340, 340, 340, 340, 385, 385, 396, - 340, 397, 396, 340, 340, 398, 388, 340, 389, 340, - 340, 340, 340, 361, 361, 390, 181, 340, 399, 340, - 392, 367, 367, 199, 340, 400, 401, 340, 374, 374, - 394, 340, 230, 402, 382, 382, 383, 383, 340, 340, - 403, 340, 396, 340, 397, 396, 340, 340, 340, 398, - - 340, 264, 361, 340, 367, 367, 340, 374, 374, 382, - 382, 383, 383, 340, 340, 340, 340, 361, 361, 367, - 367, 374, 374, 382, 382, 383, 383, 340, 340, 367, - 367, 374, 374, 382, 382, 383, 383, 340, 340, 0, - 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, - 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, - 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, - 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, - 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, - 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, - - 340, 340, 340 - } ; - -static const short int yy_nxt[3287] = - { 0, - 46, 47, 47, 48, 47, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 49, 50, 46, 46, 46, 46, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 46, 46, 46, - 46, 46, 46, 46, 51, 51, 52, 51, 46, 46, - 46, 46, 46, 46, 46, 53, 46, 54, 55, 46, - 56, 46, 46, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 46, 46, 46, 46, 46, 46, 58, 58, 59, 58, - 60, 61, 60, 62, 60, 188, 184, 60, 82, 82, - - 83, 82, 91, 185, 63, 82, 82, 83, 82, 91, - 119, 184, 92, 254, 119, 85, 255, 85, 185, 92, - 189, 96, 64, 104, 65, 104, 66, 67, 67, 68, - 67, 60, 61, 60, 62, 60, 69, 97, 60, 93, - 70, 94, 339, 122, 338, 63, 93, 120, 94, 123, - 105, 120, 105, 106, 122, 106, 125, 337, 125, 98, - 123, 336, 126, 64, 126, 65, 335, 66, 75, 75, - 75, 76, 75, 75, 75, 75, 75, 75, 75, 75, - 75, 75, 75, 77, 75, 75, 75, 75, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 78, - - 77, 77, 77, 77, 79, 75, 75, 75, 75, 75, - 75, 84, 84, 84, 85, 84, 84, 84, 84, 84, - 84, 84, 84, 84, 86, 84, 87, 88, 84, 84, - 84, 87, 87, 87, 87, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87, 87, 87, 87, 84, 84, - 84, 84, 84, 84, 96, 85, 128, 85, 153, 153, - 154, 153, 100, 101, 100, 101, 157, 157, 158, 157, - 97, 334, 129, 172, 172, 173, 172, 208, 177, 174, - 177, 177, 201, 201, 209, 201, 175, 235, 235, 333, - 235, 332, 98, 102, 130, 102, 107, 107, 107, 108, - - 107, 107, 107, 107, 107, 107, 107, 107, 109, 107, - 107, 110, 107, 107, 111, 112, 110, 110, 110, 110, - 110, 110, 110, 110, 110, 110, 110, 113, 110, 110, - 110, 110, 114, 107, 107, 115, 116, 107, 107, 128, - 139, 139, 140, 139, 186, 186, 187, 186, 215, 184, - 174, 228, 228, 241, 228, 129, 185, 175, 238, 238, - 242, 238, 241, 331, 229, 153, 153, 154, 153, 242, - 141, 216, 330, 247, 247, 142, 247, 130, 131, 132, - 132, 133, 132, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 134, 135, 131, 131, 131, 131, 135, 135, - - 135, 135, 135, 135, 135, 135, 135, 135, 135, 136, - 135, 135, 135, 135, 137, 131, 131, 131, 131, 131, - 131, 139, 139, 140, 139, 144, 144, 145, 144, 243, - 243, 329, 243, 245, 245, 246, 245, 328, 146, 157, - 157, 158, 157, 249, 249, 327, 249, 251, 251, 326, - 251, 141, 245, 245, 246, 253, 142, 325, 172, 172, - 173, 172, 324, 323, 174, 147, 149, 149, 145, 149, - 244, 175, 263, 264, 215, 179, 178, 322, 321, 150, - 265, 186, 186, 187, 186, 201, 201, 174, 201, 228, - 228, 320, 228, 317, 175, 235, 235, 216, 235, 316, - - 238, 238, 229, 238, 315, 294, 151, 152, 161, 289, - 289, 290, 289, 240, 162, 313, 163, 312, 162, 247, - 247, 162, 247, 162, 162, 163, 164, 165, 166, 167, - 311, 310, 282, 168, 180, 180, 180, 309, 180, 180, - 180, 180, 180, 180, 180, 180, 180, 180, 180, 181, - 180, 180, 180, 180, 181, 181, 181, 181, 181, 181, - 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, - 181, 180, 180, 180, 180, 180, 182, 267, 308, 207, - 275, 267, 245, 245, 246, 245, 267, 267, 267, 267, - 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, - - 267, 267, 267, 306, 249, 249, 268, 249, 267, 274, - 274, 274, 275, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 276, 274, 274, 274, 274, 276, - 276, 276, 276, 276, 276, 276, 276, 276, 276, 276, - 276, 276, 276, 276, 276, 276, 274, 274, 274, 274, - 274, 274, 283, 283, 283, 305, 283, 283, 283, 283, - 283, 283, 283, 283, 283, 283, 283, 284, 283, 283, - 283, 283, 284, 284, 284, 284, 284, 284, 284, 284, - 284, 284, 284, 284, 284, 284, 284, 284, 284, 283, - 283, 283, 283, 283, 283, 243, 243, 183, 243, 251, - - 251, 301, 251, 296, 296, 297, 296, 263, 260, 258, - 179, 303, 289, 289, 290, 289, 296, 296, 297, 296, - 263, 299, 263, 179, 319, 179, 263, 298, 294, 179, - 244, 292, 288, 287, 286, 285, 244, 302, 302, 302, - 302, 302, 302, 230, 282, 220, 280, 279, 278, 204, - 273, 272, 194, 191, 270, 263, 262, 261, 179, 302, - 318, 318, 318, 318, 318, 318, 260, 171, 258, 250, - 244, 239, 239, 237, 236, 233, 232, 230, 224, 222, - 220, 218, 318, 57, 57, 57, 57, 57, 57, 57, - 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, - - 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, - 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, - 57, 57, 57, 57, 57, 57, 71, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 71, 71, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 81, 81, 81, 81, 81, 81, 81, 81, - 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, - 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, - 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, - 81, 81, 81, 81, 81, 85, 85, 85, 85, 85, - 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, - 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, - 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, - 85, 85, 85, 85, 85, 85, 85, 85, 90, 90, - - 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, - 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, - 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, - 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, - 90, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, - - 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 103, 103, 103, - 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, - 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, - 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, - 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 121, 121, 121, 121, 121, 121, 121, - 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, - 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, - 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, - 121, 121, 121, 121, 121, 121, 124, 124, 124, 124, - 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, - 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, - 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, - 124, 124, 124, 124, 124, 124, 124, 124, 124, 127, - - 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, - 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, - 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, - 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, - 127, 127, 138, 138, 138, 138, 138, 138, 138, 138, - 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, - 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, - 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, - 138, 138, 138, 138, 138, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 148, 148, - 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, - 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, - 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, - 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, - 148, 156, 217, 212, 206, 156, 204, 203, 199, 198, - 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, - 156, 156, 156, 156, 156, 156, 156, 197, 194, 191, - - 179, 176, 156, 160, 160, 160, 160, 160, 160, 160, - 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, - 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, - 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, - 160, 160, 160, 171, 160, 160, 169, 159, 155, 340, - 169, 118, 118, 89, 89, 169, 169, 169, 169, 169, - 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, - 169, 169, 80, 74, 74, 72, 72, 169, 170, 170, - 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, - 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, - - 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, - 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, - 170, 178, 178, 178, 340, 178, 178, 178, 178, 178, - 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, - 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, - 178, 178, 178, 178, 178, 178, 178, 178, 178, 340, - 178, 178, 178, 178, 183, 183, 183, 340, 183, 183, - 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, - 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, - 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, - - 183, 183, 183, 183, 183, 183, 183, 190, 190, 190, - 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, - 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, - 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, - 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, - 192, 340, 340, 340, 340, 192, 192, 192, 192, 192, - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - 192, 192, 192, 193, 193, 193, 193, 193, 193, 193, - - 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, - 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, - 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, - 193, 193, 193, 193, 193, 193, 195, 195, 195, 340, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 340, 195, 195, 195, 195, 340, 340, 340, 340, - 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, - 340, 340, 340, 195, 195, 195, 195, 195, 195, 196, - 340, 340, 340, 196, 340, 340, 340, 340, 196, 196, - 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, - - 196, 196, 196, 196, 196, 340, 340, 340, 340, 340, - 196, 200, 200, 200, 340, 200, 200, 200, 200, 200, - 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, - 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, - 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, - 200, 200, 200, 200, 202, 340, 340, 340, 202, 340, - 340, 340, 340, 202, 202, 202, 202, 202, 202, 202, - 202, 202, 202, 202, 202, 202, 202, 202, 202, 202, - 340, 340, 340, 340, 340, 202, 205, 205, 205, 340, - 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, - - 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, - 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, - 205, 205, 205, 205, 205, 205, 205, 205, 205, 207, - 207, 207, 340, 207, 207, 207, 207, 207, 207, 207, - 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, - 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, - 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, - 207, 207, 210, 210, 210, 340, 210, 210, 210, 210, - 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, - 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, - - 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, - 340, 210, 210, 210, 210, 211, 211, 211, 340, 211, - 211, 211, 211, 211, 211, 211, 211, 340, 211, 211, - 340, 211, 211, 340, 340, 340, 340, 340, 340, 340, - 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, - 340, 340, 211, 211, 340, 340, 211, 211, 213, 340, - 340, 340, 213, 340, 340, 340, 340, 213, 213, 213, - 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, - 213, 213, 213, 213, 340, 340, 340, 340, 340, 213, - 214, 214, 214, 340, 214, 214, 214, 214, 214, 214, - - 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, - 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, - 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, - 214, 214, 214, 219, 219, 219, 219, 219, 219, 219, - 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, - 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, - 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, - 219, 219, 219, 219, 219, 219, 221, 221, 221, 340, - 221, 221, 221, 221, 221, 340, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 223, - 223, 223, 340, 223, 223, 223, 223, 223, 340, 223, - 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, - 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, - 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, - 223, 223, 225, 225, 225, 340, 225, 225, 225, 225, - 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, - 225, 340, 225, 225, 225, 225, 225, 225, 225, 225, - 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, - - 225, 225, 225, 340, 225, 226, 226, 226, 340, 226, - 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, - 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, - 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, - 226, 226, 226, 226, 226, 226, 226, 226, 227, 227, - 227, 340, 227, 227, 227, 227, 227, 227, 227, 227, - 227, 227, 227, 340, 227, 227, 227, 227, 340, 340, - 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, - 340, 340, 340, 340, 340, 227, 227, 227, 227, 227, - 227, 231, 340, 340, 340, 231, 340, 340, 340, 340, - - 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, - 231, 231, 231, 231, 231, 231, 231, 340, 340, 340, - 340, 340, 231, 234, 340, 340, 340, 340, 234, 234, - 234, 234, 234, 234, 234, 234, 234, 234, 234, 234, - 234, 234, 234, 234, 234, 234, 234, 234, 234, 234, - 234, 234, 234, 234, 234, 234, 234, 234, 234, 234, - 234, 234, 234, 234, 234, 234, 240, 240, 240, 340, - 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, - 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, - 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, - - 240, 240, 240, 240, 240, 240, 240, 240, 240, 248, - 248, 248, 340, 248, 248, 248, 248, 248, 248, 248, - 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, - 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, - 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, - 248, 248, 252, 340, 340, 340, 340, 252, 252, 252, - 252, 252, 252, 252, 252, 252, 252, 252, 252, 252, - 252, 252, 252, 252, 256, 340, 340, 340, 340, 256, - 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, - 256, 256, 256, 256, 256, 256, 257, 257, 257, 257, - - 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, - 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, - 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, - 257, 257, 257, 257, 257, 257, 257, 257, 257, 259, - 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, - 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, - 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, - 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, - 259, 259, 266, 266, 266, 340, 266, 266, 266, 266, - 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - - 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - 266, 266, 340, 266, 266, 269, 269, 269, 269, 269, - 269, 340, 340, 340, 340, 340, 340, 340, 340, 340, - 340, 340, 340, 340, 340, 340, 340, 269, 271, 271, - 271, 340, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 277, 277, 277, 277, 277, 277, 340, 340, 340, - - 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, - 340, 340, 340, 277, 281, 281, 281, 281, 281, 281, - 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, - 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, - 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, - 281, 281, 281, 281, 281, 281, 281, 291, 291, 291, - 291, 291, 291, 340, 340, 340, 340, 340, 340, 340, - 340, 340, 340, 340, 340, 340, 340, 340, 340, 291, - 293, 293, 293, 293, 293, 293, 293, 293, 293, 293, - 293, 293, 293, 293, 293, 293, 293, 293, 293, 293, - - 293, 293, 293, 293, 293, 293, 293, 293, 293, 293, - 293, 293, 293, 293, 293, 293, 293, 293, 293, 293, - 293, 293, 293, 295, 340, 340, 340, 295, 340, 340, - 340, 340, 295, 295, 295, 295, 295, 295, 295, 295, - 295, 295, 295, 295, 295, 295, 295, 295, 295, 340, - 340, 340, 340, 340, 295, 300, 340, 340, 340, 300, - 340, 340, 340, 340, 300, 300, 300, 300, 300, 300, - 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, - 300, 340, 340, 340, 340, 340, 300, 304, 304, 304, - 304, 304, 304, 340, 340, 340, 340, 340, 340, 340, - - 340, 340, 340, 340, 340, 340, 340, 340, 340, 304, - 276, 276, 276, 276, 276, 276, 276, 276, 276, 276, - 276, 276, 276, 276, 276, 276, 276, 276, 276, 276, - 276, 276, 276, 276, 276, 276, 276, 276, 276, 276, - 276, 276, 276, 276, 276, 276, 276, 276, 276, 276, - 276, 276, 276, 307, 307, 307, 307, 307, 307, 340, - 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, - 340, 340, 340, 340, 340, 307, 284, 284, 284, 340, - 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, - 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, - - 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, - 284, 284, 284, 284, 284, 284, 284, 284, 284, 314, - 314, 314, 314, 314, 314, 340, 340, 340, 340, 340, - 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, - 340, 314, 45, 340, 340, 340, 340, 340, 340, 340, - 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, - 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, - 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, - 340, 340, 340, 340, 340, 340 - } ; - -static const short int yy_chk[3287] = - { 0, - 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, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 70, 66, 3, 11, 11, - - 11, 11, 17, 66, 3, 12, 12, 12, 12, 18, - 29, 98, 17, 166, 30, 23, 166, 24, 98, 18, - 70, 19, 3, 23, 3, 24, 3, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 19, 4, 17, - 4, 17, 329, 31, 328, 4, 18, 29, 18, 31, - 23, 30, 24, 23, 32, 24, 33, 327, 34, 19, - 32, 326, 33, 4, 34, 4, 325, 4, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 20, 21, 35, 22, 47, 47, - 47, 47, 21, 21, 22, 22, 51, 51, 51, 51, - 20, 324, 35, 58, 58, 58, 58, 102, 62, 58, - 62, 62, 82, 82, 102, 82, 58, 139, 139, 323, - 139, 322, 20, 21, 35, 22, 25, 25, 25, 25, - - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 36, - 39, 39, 39, 39, 67, 67, 67, 67, 111, 106, - 67, 132, 132, 147, 132, 36, 106, 67, 144, 144, - 147, 144, 151, 321, 132, 153, 153, 153, 153, 151, - 39, 111, 320, 160, 160, 39, 160, 36, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 40, 40, 40, 40, 43, 43, 43, 43, 149, - 149, 317, 149, 155, 155, 155, 155, 315, 43, 157, - 157, 157, 157, 161, 161, 313, 161, 163, 163, 312, - 163, 40, 165, 165, 165, 165, 40, 311, 172, 172, - 172, 172, 310, 309, 172, 43, 44, 44, 44, 44, - 149, 172, 178, 179, 214, 178, 179, 308, 306, 44, - 179, 186, 186, 186, 186, 201, 201, 186, 201, 228, - 228, 305, 228, 301, 186, 235, 235, 214, 235, 299, - - 238, 238, 228, 238, 298, 293, 44, 44, 54, 239, - 239, 239, 239, 292, 54, 288, 54, 287, 54, 247, - 247, 54, 247, 54, 54, 54, 54, 54, 54, 54, - 286, 285, 281, 54, 65, 65, 65, 280, 65, 65, - 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, - 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, - 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, - 65, 65, 65, 65, 65, 65, 65, 181, 279, 278, - 276, 181, 245, 245, 245, 245, 181, 181, 181, 181, - 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, - - 181, 181, 181, 273, 249, 249, 181, 249, 181, 199, - 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, - 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, - 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, - 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, - 199, 199, 230, 230, 230, 272, 230, 230, 230, 230, - 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, - 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, - 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, - 230, 230, 230, 230, 230, 243, 243, 270, 243, 251, - - 251, 262, 251, 253, 253, 253, 253, 265, 259, 257, - 265, 265, 289, 289, 289, 289, 296, 296, 296, 296, - 303, 255, 318, 303, 303, 318, 319, 254, 250, 319, - 244, 242, 237, 236, 233, 232, 243, 264, 264, 264, - 264, 264, 264, 229, 222, 219, 218, 217, 209, 204, - 198, 197, 193, 190, 185, 264, 176, 175, 264, 264, - 302, 302, 302, 302, 302, 302, 174, 170, 168, 162, - 152, 150, 146, 142, 141, 137, 136, 134, 126, 123, - 117, 114, 302, 341, 341, 341, 341, 341, 341, 341, - 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, - - 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, - 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, - 341, 341, 341, 341, 341, 341, 342, 342, 342, 342, - 342, 342, 342, 342, 342, 342, 342, 342, 342, 342, - 342, 342, 342, 342, 342, 342, 342, 342, 342, 342, - 342, 342, 342, 342, 342, 342, 342, 342, 342, 342, - 342, 342, 342, 342, 342, 342, 342, 342, 342, 343, - 343, 343, 343, 343, 343, 343, 343, 343, 343, 343, - 343, 343, 343, 343, 343, 343, 343, 343, 343, 343, - 343, 343, 343, 343, 343, 343, 343, 343, 343, 343, - - 343, 343, 343, 343, 343, 343, 343, 343, 343, 343, - 343, 343, 344, 344, 344, 344, 344, 344, 344, 344, - 344, 344, 344, 344, 344, 344, 344, 344, 344, 344, - 344, 344, 344, 344, 344, 344, 344, 344, 344, 344, - 344, 344, 344, 344, 344, 344, 344, 344, 344, 344, - 344, 344, 344, 344, 344, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 346, 346, - - 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - 346, 347, 347, 347, 347, 347, 347, 347, 347, 347, - 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, - 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, - 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, - 347, 347, 347, 347, 348, 348, 348, 348, 348, 348, - 348, 348, 348, 348, 348, 348, 348, 348, 348, 348, - - 348, 348, 348, 348, 348, 348, 348, 348, 348, 348, - 348, 348, 348, 348, 348, 348, 348, 348, 348, 348, - 348, 348, 348, 348, 348, 348, 348, 349, 349, 349, - 349, 349, 349, 349, 349, 349, 349, 349, 349, 349, - 349, 349, 349, 349, 349, 349, 349, 349, 349, 349, - 349, 349, 349, 349, 349, 349, 349, 349, 349, 349, - 349, 349, 349, 349, 349, 349, 349, 349, 349, 349, - 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - - 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - 350, 350, 350, 351, 351, 351, 351, 351, 351, 351, - 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - 351, 351, 351, 351, 351, 351, 352, 352, 352, 352, - 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - 352, 352, 352, 352, 352, 352, 352, 352, 352, 353, - - 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, - 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, - 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, - 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, - 353, 353, 354, 354, 354, 354, 354, 354, 354, 354, - 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, - 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, - 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, - 354, 354, 354, 354, 354, 355, 355, 355, 355, 355, - 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, - - 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, - 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, - 355, 355, 355, 355, 355, 355, 355, 355, 356, 356, - 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, - 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, - 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, - 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, - 356, 357, 113, 109, 100, 357, 94, 88, 80, 79, - 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, - 357, 357, 357, 357, 357, 357, 357, 78, 73, 71, - - 64, 61, 357, 358, 358, 358, 358, 358, 358, 358, - 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, - 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, - 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, - 358, 358, 358, 56, 358, 358, 359, 53, 49, 45, - 359, 28, 27, 16, 15, 359, 359, 359, 359, 359, - 359, 359, 359, 359, 359, 359, 359, 359, 359, 359, - 359, 359, 10, 8, 7, 6, 5, 359, 360, 360, - 360, 360, 360, 360, 360, 360, 360, 360, 360, 360, - 360, 360, 360, 360, 360, 360, 360, 360, 360, 360, - - 360, 360, 360, 360, 360, 360, 360, 360, 360, 360, - 360, 360, 360, 360, 360, 360, 360, 360, 360, 360, - 360, 361, 361, 361, 0, 361, 361, 361, 361, 361, - 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, - 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, - 361, 361, 361, 361, 361, 361, 361, 361, 361, 0, - 361, 361, 361, 361, 362, 362, 362, 0, 362, 362, - 362, 362, 362, 362, 362, 362, 362, 362, 362, 362, - 362, 362, 362, 362, 362, 362, 362, 362, 362, 362, - 362, 362, 362, 362, 362, 362, 362, 362, 362, 362, - - 362, 362, 362, 362, 362, 362, 362, 363, 363, 363, - 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, - 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, - 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, - 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, - 364, 0, 0, 0, 0, 364, 364, 364, 364, 364, - 364, 364, 364, 364, 364, 364, 364, 364, 364, 364, - 364, 364, 364, 364, 364, 364, 364, 364, 364, 364, - 364, 364, 364, 364, 364, 364, 364, 364, 364, 364, - 364, 364, 364, 365, 365, 365, 365, 365, 365, 365, - - 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, - 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, - 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, - 365, 365, 365, 365, 365, 365, 366, 366, 366, 0, - 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, - 366, 0, 366, 366, 366, 366, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 366, 366, 366, 366, 366, 366, 367, - 0, 0, 0, 367, 0, 0, 0, 0, 367, 367, - 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - - 367, 367, 367, 367, 367, 0, 0, 0, 0, 0, - 367, 368, 368, 368, 0, 368, 368, 368, 368, 368, - 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, - 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, - 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, - 368, 368, 368, 368, 369, 0, 0, 0, 369, 0, - 0, 0, 0, 369, 369, 369, 369, 369, 369, 369, - 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, - 0, 0, 0, 0, 0, 369, 370, 370, 370, 0, - 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, - - 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, - 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, - 370, 370, 370, 370, 370, 370, 370, 370, 370, 371, - 371, 371, 0, 371, 371, 371, 371, 371, 371, 371, - 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, - 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, - 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, - 371, 371, 372, 372, 372, 0, 372, 372, 372, 372, - 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, - 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, - - 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, - 0, 372, 372, 372, 372, 373, 373, 373, 0, 373, - 373, 373, 373, 373, 373, 373, 373, 0, 373, 373, - 0, 373, 373, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 373, 373, 0, 0, 373, 373, 374, 0, - 0, 0, 374, 0, 0, 0, 0, 374, 374, 374, - 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, - 374, 374, 374, 374, 0, 0, 0, 0, 0, 374, - 375, 375, 375, 0, 375, 375, 375, 375, 375, 375, - - 375, 375, 375, 375, 375, 375, 375, 375, 375, 375, - 375, 375, 375, 375, 375, 375, 375, 375, 375, 375, - 375, 375, 375, 375, 375, 375, 375, 375, 375, 375, - 375, 375, 375, 376, 376, 376, 376, 376, 376, 376, - 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, - 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, - 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, - 376, 376, 376, 376, 376, 376, 377, 377, 377, 0, - 377, 377, 377, 377, 377, 0, 377, 377, 377, 377, - 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, - - 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, - 377, 377, 377, 377, 377, 377, 377, 377, 377, 378, - 378, 378, 0, 378, 378, 378, 378, 378, 0, 378, - 378, 378, 378, 378, 378, 378, 378, 378, 378, 378, - 378, 378, 378, 378, 378, 378, 378, 378, 378, 378, - 378, 378, 378, 378, 378, 378, 378, 378, 378, 378, - 378, 378, 379, 379, 379, 0, 379, 379, 379, 379, - 379, 379, 379, 379, 379, 379, 379, 379, 379, 379, - 379, 0, 379, 379, 379, 379, 379, 379, 379, 379, - 379, 379, 379, 379, 379, 379, 379, 379, 379, 379, - - 379, 379, 379, 0, 379, 380, 380, 380, 0, 380, - 380, 380, 380, 380, 380, 380, 380, 380, 380, 380, - 380, 380, 380, 380, 380, 380, 380, 380, 380, 380, - 380, 380, 380, 380, 380, 380, 380, 380, 380, 380, - 380, 380, 380, 380, 380, 380, 380, 380, 381, 381, - 381, 0, 381, 381, 381, 381, 381, 381, 381, 381, - 381, 381, 381, 0, 381, 381, 381, 381, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 381, 381, 381, 381, 381, - 381, 382, 0, 0, 0, 382, 0, 0, 0, 0, - - 382, 382, 382, 382, 382, 382, 382, 382, 382, 382, - 382, 382, 382, 382, 382, 382, 382, 0, 0, 0, - 0, 0, 382, 383, 0, 0, 0, 0, 383, 383, - 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, - 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, - 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, - 383, 383, 383, 383, 383, 383, 384, 384, 384, 0, - 384, 384, 384, 384, 384, 384, 384, 384, 384, 384, - 384, 384, 384, 384, 384, 384, 384, 384, 384, 384, - 384, 384, 384, 384, 384, 384, 384, 384, 384, 384, - - 384, 384, 384, 384, 384, 384, 384, 384, 384, 385, - 385, 385, 0, 385, 385, 385, 385, 385, 385, 385, - 385, 385, 385, 385, 385, 385, 385, 385, 385, 385, - 385, 385, 385, 385, 385, 385, 385, 385, 385, 385, - 385, 385, 385, 385, 385, 385, 385, 385, 385, 385, - 385, 385, 386, 0, 0, 0, 0, 386, 386, 386, - 386, 386, 386, 386, 386, 386, 386, 386, 386, 386, - 386, 386, 386, 386, 387, 0, 0, 0, 0, 387, - 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, - 387, 387, 387, 387, 387, 387, 388, 388, 388, 388, - - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 388, 388, 388, 388, 388, 389, - 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, - 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, - 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, - 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, - 389, 389, 390, 390, 390, 0, 390, 390, 390, 390, - 390, 390, 390, 390, 390, 390, 390, 390, 390, 390, - - 390, 390, 390, 390, 390, 390, 390, 390, 390, 390, - 390, 390, 390, 390, 390, 390, 390, 390, 390, 390, - 390, 390, 0, 390, 390, 391, 391, 391, 391, 391, - 391, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 391, 392, 392, - 392, 0, 392, 392, 392, 392, 392, 392, 392, 392, - 392, 392, 392, 392, 392, 392, 392, 392, 392, 392, - 392, 392, 392, 392, 392, 392, 392, 392, 392, 392, - 392, 392, 392, 392, 392, 392, 392, 392, 392, 392, - 392, 393, 393, 393, 393, 393, 393, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 393, 394, 394, 394, 394, 394, 394, - 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, - 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, - 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, - 394, 394, 394, 394, 394, 394, 394, 395, 395, 395, - 395, 395, 395, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 395, - 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, - 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, - - 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, - 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, - 396, 396, 396, 397, 0, 0, 0, 397, 0, 0, - 0, 0, 397, 397, 397, 397, 397, 397, 397, 397, - 397, 397, 397, 397, 397, 397, 397, 397, 397, 0, - 0, 0, 0, 0, 397, 398, 0, 0, 0, 398, - 0, 0, 0, 0, 398, 398, 398, 398, 398, 398, - 398, 398, 398, 398, 398, 398, 398, 398, 398, 398, - 398, 0, 0, 0, 0, 0, 398, 399, 399, 399, - 399, 399, 399, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 399, - 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, - 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, - 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, - 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, - 400, 400, 400, 401, 401, 401, 401, 401, 401, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 401, 402, 402, 402, 0, - 402, 402, 402, 402, 402, 402, 402, 402, 402, 402, - 402, 402, 402, 402, 402, 402, 402, 402, 402, 402, - - 402, 402, 402, 402, 402, 402, 402, 402, 402, 402, - 402, 402, 402, 402, 402, 402, 402, 402, 402, 403, - 403, 403, 403, 403, 403, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 403, 340, 340, 340, 340, 340, 340, 340, 340, - 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, - 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, - 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, - 340, 340, 340, 340, 340, 340 - } ; - -static yy_ste_type yy_last_accepting_state; -static YY_CHAR *yy_last_accepting_cpos; - -/* the intent behind this definition is that it'll catch - * any uses of REJECT which flex missed - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymrused_but_not_detected -#define YY_MORE_ADJ 0 - -/* these variables are all declared out here so that section 3 code can - * manipulate them - */ -/* points to current character in buffer */ -static YY_CHAR *yy_c_buf_p = (YY_CHAR *) 0; -static int yy_init = 1; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* flag which is used to allow yywrap()'s to do buffer switches - * instead of setting up a fresh yyin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; - -static yy_ste_type yy_get_previous_state YY_PROTO(( void )); -static yy_ste_type yy_try_NUL_trans YY_PROTO(( yy_ste_type current_state )); -static int yy_get_next_buffer YY_PROTO(( void )); -static void yyunput YY_PROTO(( YY_CHAR c, YY_CHAR *buf_ptr )); -void yyrestrt YY_PROTO(( FILE *input_file )); -void yyswtobf YY_PROTO(( YY_BUFFER_STATE new_buffer )); -void yyldbfst YY_PROTO(( void )); -YY_BUFFER_STATE yycrbffr YY_PROTO(( FILE *file, int size )); -void yydlbffr YY_PROTO(( YY_BUFFER_STATE b )); -void yyinbffr YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); - -#define yy_new_buffer yycrbffr - -#ifdef __cplusplus -static int yyinput YY_PROTO(( void )); -#else -static int input YY_PROTO(( void )); -#endif - -YY_DECL - { - register yy_ste_type yy_current_state; - register YY_CHAR *yy_cp, *yy_bp; - register int yy_act; - - - static int bracelevel, didadef; - int i, indented_code, checking_used, new_xlation; - int doing_codeblock = false; - Char nmdef[MAXLINE], myesc(); - - - if ( yy_init ) - { - YY_USER_INIT; - - if ( ! yy_start ) - yy_start = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( yy_current_buffer ) - yyinbffr( yy_current_buffer, yyin ); - else - yy_current_buffer = yycrbffr( yyin, YY_BUF_SIZE ); - - yyldbfst(); - - yy_init = 0; - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = yy_c_buf_p; - - /* support of yytext */ - *yy_cp = yy_hold_char; - - /* yy_bp points to the position in yy_ch_buf of the start of the - * current run. - */ - yy_bp = yy_cp; - - yy_current_state = yy_start; - if ( yy_bp[-1] == '\n' ) - ++yy_current_state; -yy_match: - do - { - register YY_CHAR yy_c = yy_ec[*yy_cp]; - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while(yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state) - { - yy_current_state = yy_def[yy_current_state]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - ++yy_cp; - } - while ( yy_current_state != 340 ); - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - - YY_DO_BEFORE_ACTION; - YY_USER_ACTION; - -do_action: /* this label is used only to access EOF actions */ - - - switch ( yy_act ) - { - case 0: /* must backtrack */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yy_hold_char; - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; - goto yy_find_action; - -case 1: -# line 90 "" -indented_code = true; BEGIN(CODEBLOCK); - YY_BREAK -case 2: -# line 91 "" -++linenum; /* treat as a comment */ - YY_BREAK -case 3: -# line 92 "" -ECHO; BEGIN(C_COMMENT); - YY_BREAK -case 4: -# line 93 "" -return ( SCDECL ); - YY_BREAK -case 5: -# line 94 "" -return ( XSCDECL ); - YY_BREAK -case 6: -# line 95 "" -{ - ++linenum; - lndirout( stdout ); - indented_code = false; - BEGIN(CODEBLOCK); - } - YY_BREAK -case 7: -# line 102 "" -return ( WHITESPACE ); - YY_BREAK -case 8: -# line 104 "" -{ - sectnum = 2; - lndirout( stdout ); - BEGIN(SECT2PROLOG); - return ( SECTEND ); - } - YY_BREAK -case 9: -# line 111 "" -{ - pptmsg( "warning - %%used/%%unused have been deprecated" ); - checking_used = REALLY_USED; BEGIN(USED_LIST); - } - YY_BREAK -case 10: -# line 115 "" -{ - checking_used = REALLY_NOT_USED; BEGIN(USED_LIST); - pptmsg( "warning - %%used/%%unused have been deprecated" ); - checking_used = REALLY_NOT_USED; BEGIN(USED_LIST); - } - YY_BREAK -case 11: -# line 122 "" -{ -#ifdef NOTDEF - fprintf( stderr, - "old-style lex command at line %d ignored:\n\t%s", - linenum, yytext ); -#endif - ++linenum; - } - YY_BREAK -case 12: -# line 131 "" -/* ignore old lex directive */ - YY_BREAK -case 13: -# line 133 "" -{ - ++linenum; - xlation = - (int *) malloc( sizeof( int ) * (unsigned) csize ); - - if ( ! xlation ) - flxfatal( - "dynamic memory failure building %t table" ); - - for ( i = 0; i < csize; ++i ) - xlation[i] = 0; - - nuxlatns = 0; - - BEGIN(XLATION); - } - YY_BREAK -case 14: -# line 150 "" -synerr( "unrecognized '%' directive" ); - YY_BREAK -case 15: -# line 152 "" -{ - (void) strcpy( nmstr, (char *) yytext ); - didadef = false; - BEGIN(PICKUPDEF); - } - YY_BREAK -case 16: -# line 158 "" -RETURNNAME; - YY_BREAK -case 17: -# line 159 "" -++linenum; /* allows blank lines in section 1 */ - YY_BREAK -case 18: -# line 160 "" -++linenum; return ( '\n' ); - YY_BREAK -case 19: -# line 161 "" -synerr( "illegal character" ); BEGIN(RECOVER); - YY_BREAK -case 20: -# line 164 "" -ECHO; BEGIN(INITIAL); - YY_BREAK -case 21: -# line 165 "" -++linenum; ECHO; BEGIN(INITIAL); - YY_BREAK -case 22: -# line 166 "" -ECHO; - YY_BREAK -case 23: -# line 167 "" -ECHO; - YY_BREAK -case 24: -# line 168 "" -++linenum; ECHO; - YY_BREAK -case 25: -# line 171 "" -++linenum; BEGIN(INITIAL); - YY_BREAK -case 26: -# line 172 "" -ECHO; CHECK_REJECT(yytext); - YY_BREAK -case 27: -# line 173 "" -ECHO; CHECK_YYMORE(yytext); - YY_BREAK -case 28: -# line 174 "" -ECHO; - YY_BREAK -case 29: -# line 175 "" -{ - ++linenum; - ECHO; - if ( indented_code ) - BEGIN(INITIAL); - } - YY_BREAK -case 30: -# line 183 "" -/* separates name and definition */ - YY_BREAK -case 31: -# line 185 "" -{ - (void) strcpy( (char *) nmdef, (char *) yytext ); - - for ( i = strlen( (char *) nmdef ) - 1; - i >= 0 && - nmdef[i] == ' ' || nmdef[i] == '\t'; - --i ) - ; - - nmdef[i + 1] = '\0'; - - ndinstal( nmstr, nmdef ); - didadef = true; - } - YY_BREAK -case 32: -# line 200 "" -{ - if ( ! didadef ) - synerr( "incomplete name definition" ); - BEGIN(INITIAL); - ++linenum; - } - YY_BREAK -case 33: -# line 207 "" -++linenum; BEGIN(INITIAL); RETURNNAME; - YY_BREAK -case 34: -# line 210 "" -++linenum; BEGIN(INITIAL); - YY_BREAK -case 35: -# line 211 "" - - YY_BREAK -case 36: -# line 212 "" -{ - if ( allupper( yytext ) ) - rjctused = checking_used; - else - synerr( "unrecognized %used/%unused construct" ); - } - YY_BREAK -case 37: -# line 218 "" -{ - if ( alllower( yytext ) ) - yymrreus = checking_used; - else - synerr( "unrecognized %used/%unused construct" ); - } - YY_BREAK -case 38: -# line 224 "" -synerr( "unrecognized %used/%unused construct" ); - YY_BREAK -case 39: -# line 227 "" -++linenum; BEGIN(INITIAL); - YY_BREAK -case 40: -# line 228 "" -++nuxlatns; new_xlation = true; - YY_BREAK -case 41: -# line 229 "" -synerr( "bad row in translation table" ); - YY_BREAK -case 42: -# line 230 "" -/* ignore whitespace */ - YY_BREAK -case 43: -# line 232 "" -{ - xlation[myesc( yytext )] = - (new_xlation ? nuxlatns : -nuxlatns); - new_xlation = false; - } - YY_BREAK -case 44: -# line 237 "" -{ - xlation[yytext[0]] = - (new_xlation ? nuxlatns : -nuxlatns); - new_xlation = false; - } - YY_BREAK -case 45: -# line 243 "" -++linenum; - YY_BREAK -case 46: -*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ -yy_c_buf_p = yy_cp -= 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ -# line 246 "" -{ - ++linenum; - ACTION_ECHO; - MARK_END_OF_PROLOG; - BEGIN(SECT2); - } - YY_BREAK -case 47: -# line 253 "" -++linenum; ACTION_ECHO; - YY_BREAK -case YY_STATE_EOF(SECT2PROLOG): -# line 255 "" -MARK_END_OF_PROLOG; yyterminate(); - YY_BREAK -case 49: -# line 257 "" -++linenum; /* allow blank lines in section 2 */ - YY_BREAK -case 50: -# line 259 "" -{ - indented_code = (yytext[0] != '%'); - doing_codeblock = true; - bracelevel = 1; - - if ( indented_code ) - ACTION_ECHO; - - BEGIN(CODEBLOCK_2); - } - YY_BREAK -case 51: -# line 270 "" -BEGIN(SC); return ( '<' ); - YY_BREAK -case 52: -# line 271 "" -return ( '^' ); - YY_BREAK -case 53: -# line 272 "" -BEGIN(QUOTE); return ( '"' ); - YY_BREAK -case 54: -*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ -yy_c_buf_p = yy_cp = yy_bp + 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ -# line 273 "" -BEGIN(NUM); return ( '{' ); - YY_BREAK -case 55: -# line 274 "" -BEGIN(BRACEERROR); - YY_BREAK -case 56: -*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ -yy_c_buf_p = yy_cp = yy_bp + 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ -# line 275 "" -return ( '$' ); - YY_BREAK -case 57: -# line 277 "" -{ - bracelevel = 1; - BEGIN(PERCENT_BRACE_ACTION); - return ( '\n' ); - } - YY_BREAK -case 58: -# line 282 "" -cntdactn = true; ++linenum; return ( '\n' ); - YY_BREAK -case 59: -# line 284 "" -{ - /* this rule is separate from the one below because - * otherwise we get variable trailing context, so - * we can't build the scanner using -{f,F} - */ - bracelevel = 0; - cntdactn = false; - BEGIN(ACTION); - return ( '\n' ); - } - YY_BREAK -case 60: -*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ -yy_c_buf_p = yy_cp -= 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ -# line 295 "" -{ - bracelevel = 0; - cntdactn = false; - BEGIN(ACTION); - return ( '\n' ); - } - YY_BREAK -case 61: -# line 302 "" -++linenum; return ( '\n' ); - YY_BREAK -case 62: -# line 304 "" -return ( EOF_OP ); - YY_BREAK -case 63: -# line 306 "" -{ - sectnum = 3; - BEGIN(SECT3); - return ( EOF ); /* to stop the parser */ - } - YY_BREAK -case 64: -# line 312 "" -{ - int cclval; - - (void) strcpy( nmstr, (char *) yytext ); - - /* check to see if we've already encountered this ccl */ - if ( (cclval = ccllookp( (Char *) nmstr )) ) - { - yylval = cclval; - ++cclreuse; - return ( PREVCCL ); - } - else - { - /* we fudge a bit. We know that this ccl will - * soon be numbered as lastccl + 1 by cclinit - */ - cclnstal( (Char *) nmstr, lastccl + 1 ); - - /* push back everything but the leading bracket - * so the ccl can be rescanned - */ - PUT_BACK_STRING((Char *) nmstr, 1); - - BEGIN(FIRSTCCL); - return ( '[' ); - } - } - YY_BREAK -case 65: -# line 341 "" -{ - register Char *nmdefptr; - Char *ndlookup(); - - (void) strcpy( nmstr, (char *) yytext ); - nmstr[yyleng - 1] = '\0'; /* chop trailing brace */ - - /* lookup from "nmstr + 1" to chop leading brace */ - if ( ! (nmdefptr = ndlookup( nmstr + 1 )) ) - synerr( "undefined {name}" ); - - else - { /* push back name surrounded by ()'s */ - unput(')'); - PUT_BACK_STRING(nmdefptr, 0); - unput('('); - } - } - YY_BREAK -case 66: -# line 360 "" -return ( yytext[0] ); - YY_BREAK -case 67: -# line 361 "" -RETURNCHAR; - YY_BREAK -case 68: -# line 362 "" -++linenum; return ( '\n' ); - YY_BREAK -case 69: -# line 365 "" -return ( ',' ); - YY_BREAK -case 70: -# line 366 "" -BEGIN(SECT2); return ( '>' ); - YY_BREAK -case 71: -*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ -yy_c_buf_p = yy_cp = yy_bp + 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ -# line 367 "" -BEGIN(CARETISBOL); return ( '>' ); - YY_BREAK -case 72: -# line 368 "" -RETURNNAME; - YY_BREAK -case 73: -# line 369 "" -synerr( "bad start condition name" ); - YY_BREAK -case 74: -# line 371 "" -BEGIN(SECT2); return ( '^' ); - YY_BREAK -case 75: -# line 374 "" -RETURNCHAR; - YY_BREAK -case 76: -# line 375 "" -BEGIN(SECT2); return ( '"' ); - YY_BREAK -case 77: -# line 377 "" -{ - synerr( "missing quote" ); - BEGIN(SECT2); - ++linenum; - return ( '"' ); - } - YY_BREAK -case 78: -*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ -yy_c_buf_p = yy_cp = yy_bp + 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ -# line 385 "" -BEGIN(CCL); return ( '^' ); - YY_BREAK -case 79: -*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ -yy_c_buf_p = yy_cp = yy_bp + 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ -# line 386 "" -return ( '^' ); - YY_BREAK -case 80: -# line 387 "" -BEGIN(CCL); yylval = '-'; return ( CHAR ); - YY_BREAK -case 81: -# line 388 "" -BEGIN(CCL); RETURNCHAR; - YY_BREAK -case 82: -*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ -yy_c_buf_p = yy_cp = yy_bp + 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ -# line 390 "" -return ( '-' ); - YY_BREAK -case 83: -# line 391 "" -RETURNCHAR; - YY_BREAK -case 84: -# line 392 "" -BEGIN(SECT2); return ( ']' ); - YY_BREAK -case 85: -# line 395 "" -{ - yylval = myctoi( yytext ); - return ( NUMBER ); - } - YY_BREAK -case 86: -# line 400 "" -return ( ',' ); - YY_BREAK -case 87: -# line 401 "" -BEGIN(SECT2); return ( '}' ); - YY_BREAK -case 88: -# line 403 "" -{ - synerr( "bad character inside {}'s" ); - BEGIN(SECT2); - return ( '}' ); - } - YY_BREAK -case 89: -# line 409 "" -{ - synerr( "missing }" ); - BEGIN(SECT2); - ++linenum; - return ( '}' ); - } - YY_BREAK -case 90: -# line 417 "" -synerr( "bad name in {}'s" ); BEGIN(SECT2); - YY_BREAK -case 91: -# line 418 "" -synerr( "missing }" ); ++linenum; BEGIN(SECT2); - YY_BREAK -case 92: -# line 421 "" -bracelevel = 0; - YY_BREAK -case 93: -# line 422 "" -{ - ACTION_ECHO; - CHECK_REJECT(yytext); - } - YY_BREAK -case 94: -# line 426 "" -{ - ACTION_ECHO; - CHECK_YYMORE(yytext); - } - YY_BREAK -case 95: -# line 430 "" -ACTION_ECHO; - YY_BREAK -case 96: -# line 431 "" -{ - ++linenum; - ACTION_ECHO; - if ( bracelevel == 0 || - (doing_codeblock && indented_code) ) - { - if ( ! doing_codeblock ) - fputs( "\tYY_BREAK\n", tmpactfl ); - - doing_codeblock = false; - BEGIN(SECT2); - } - } - YY_BREAK - /* Reject and YYmore() are checked for above, in PERCENT_BRACE_ACTION */ -case 97: -# line 447 "" -ACTION_ECHO; ++bracelevel; - YY_BREAK -case 98: -# line 448 "" -ACTION_ECHO; --bracelevel; - YY_BREAK -case 99: -# line 449 "" -ACTION_ECHO; - YY_BREAK -case 100: -# line 450 "" -ACTION_ECHO; - YY_BREAK -case 101: -# line 451 "" -ACTION_ECHO; BEGIN(ACTION_COMMENT); - YY_BREAK -case 102: -# line 452 "" -ACTION_ECHO; /* character constant */ - YY_BREAK -case 103: -# line 453 "" -ACTION_ECHO; BEGIN(ACTION_STRING); - YY_BREAK -case 104: -# line 454 "" -{ - ++linenum; - ACTION_ECHO; - if ( bracelevel == 0 ) - { - fputs( "\tYY_BREAK\n", tmpactfl ); - BEGIN(SECT2); - } - } - YY_BREAK -case 105: -# line 463 "" -ACTION_ECHO; - YY_BREAK -case 106: -# line 465 "" -ACTION_ECHO; BEGIN(ACTION); - YY_BREAK -case 107: -# line 466 "" -ACTION_ECHO; - YY_BREAK -case 108: -# line 467 "" -ACTION_ECHO; - YY_BREAK -case 109: -# line 468 "" -++linenum; ACTION_ECHO; - YY_BREAK -case 110: -# line 469 "" -ACTION_ECHO; - YY_BREAK -case 111: -# line 471 "" -ACTION_ECHO; - YY_BREAK -case 112: -# line 472 "" -ACTION_ECHO; - YY_BREAK -case 113: -# line 473 "" -++linenum; ACTION_ECHO; - YY_BREAK -case 114: -# line 474 "" -ACTION_ECHO; BEGIN(ACTION); - YY_BREAK -case 115: -# line 475 "" -ACTION_ECHO; - YY_BREAK -case YY_STATE_EOF(ACTION): -case YY_STATE_EOF(ACTION_COMMENT): -case YY_STATE_EOF(ACTION_STRING): -# line 477 "" -{ - synerr( "EOF encountered inside an action" ); - yyterminate(); - } - YY_BREAK -case 117: -# line 483 "" -{ - yylval = myesc( yytext ); - return ( CHAR ); - } - YY_BREAK -case 118: -# line 488 "" -{ - yylval = myesc( yytext ); - BEGIN(CCL); - return ( CHAR ); - } - YY_BREAK -case 119: -# line 495 "" -ECHO; - YY_BREAK -case 120: -# line 496 "" -YY_FATAL_ERROR( "flex scanner jammed" ); - YY_BREAK -case YY_STATE_EOF(INITIAL): -case YY_STATE_EOF(SECT2): -case YY_STATE_EOF(SECT3): -case YY_STATE_EOF(CODEBLOCK): -case YY_STATE_EOF(PICKUPDEF): -case YY_STATE_EOF(SC): -case YY_STATE_EOF(CARETISBOL): -case YY_STATE_EOF(NUM): -case YY_STATE_EOF(QUOTE): -case YY_STATE_EOF(FIRSTCCL): -case YY_STATE_EOF(CCL): -case YY_STATE_EOF(RECOVER): -case YY_STATE_EOF(BRACEERROR): -case YY_STATE_EOF(C_COMMENT): -case YY_STATE_EOF(PERCENT_BRACE_ACTION): -case YY_STATE_EOF(USED_LIST): -case YY_STATE_EOF(CODEBLOCK_2): -case YY_STATE_EOF(XLATION): - yyterminate(); - - case YY_END_OF_BUFFER: - { - /* amount of text matched not including the EOB char */ - int yy_amount_of_matched_text = yy_cp - yytext - 1; - - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yy_hold_char; - - /* note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the end- - * of-buffer state). Contrast this with the test in yyinput(). - */ - if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) - /* this was really a NUL */ - { - yy_ste_type yy_next_state; - - yy_c_buf_p = yytext + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - /* okay, we're now positioned to make the - * NUL transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we - * don't want to build jamming into it because - * then it will run more slowly) - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state ); - - yy_bp = yytext + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* consume the NUL */ - yy_cp = ++yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer() ) - { - case EOB_ACT_END_OF_FILE: - { - yy_did_buffer_switch_on_eof = 0; - - if ( yywrap() ) - { - /* note: because we've taken care in - * yy_get_next_buffer() to have set up yytext, - * we can now set up yy_c_buf_p so that if some - * total hoser (like flex itself) wants - * to call the scanner after we return the - * YY_NULL, it'll still work - another YY_NULL - * will get returned. - */ - yy_c_buf_p = yytext + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF((yy_start - 1) / 2); - goto do_action; - } - - else - { - if ( ! yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - } - break; - - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = yytext + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - yy_cp = yy_c_buf_p; - yy_bp = yytext + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yy_c_buf_p = - &yy_current_buffer->yy_ch_buf[yy_n_chars]; - - yy_current_state = yy_get_previous_state(); - - yy_cp = yy_c_buf_p; - yy_bp = yytext + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: -#ifdef FLEX_DEBUG - printf( "action # %d\n", yy_act ); -#endif - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } - } - } - - -/* yy_get_next_buffer - try to read in a new buffer - * - * synopsis - * int yy_get_next_buffer(); - * - * returns a code representing an action - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ - -static int yy_get_next_buffer() - - { - register YY_CHAR *dest = yy_current_buffer->yy_ch_buf; - register YY_CHAR *source = yytext - 1; /* copy prev. char, too */ - register int number_to_move, i; - int ret_val; - - if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - /* try to read more data */ - - /* first move last chars to start of buffer */ - number_to_move = yy_c_buf_p - yytext; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( yy_current_buffer->yy_eof_status != EOF_NOT_SEEN ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - yy_n_chars = 0; - - else - { - int num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1; - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - else if ( num_to_read <= 0 ) - YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); - - /* read in more data */ - YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), - yy_n_chars, num_to_read ); - } - - if ( yy_n_chars == 0 ) - { - if ( number_to_move == 1 ) - { - ret_val = EOB_ACT_END_OF_FILE; - yy_current_buffer->yy_eof_status = EOF_DONE; - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - yy_current_buffer->yy_eof_status = EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - yy_n_chars += number_to_move; - yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; - yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - /* yytext begins at the second character in yy_ch_buf; the first - * character is the one which preceded it before reading in the latest - * buffer; it needs to be kept around in case it's a newline, so - * yy_get_previous_state() will have with '^' rules active - */ - - yytext = &yy_current_buffer->yy_ch_buf[1]; - - return ( ret_val ); - } - - -/* yy_get_previous_state - get the state just before the EOB char was reached - * - * synopsis - * yy_ste_type yy_get_previous_state(); - */ - -static yy_ste_type yy_get_previous_state() - - { - register yy_ste_type yy_current_state; - register YY_CHAR *yy_cp; - - register YY_CHAR *yy_bp = yytext; - - yy_current_state = yy_start; - if ( yy_bp[-1] == '\n' ) - ++yy_current_state; - - for ( yy_cp = yytext + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[*yy_cp] : 1); - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = yy_def[yy_current_state]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - } - - return ( yy_current_state ); - } - - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - -#ifdef YY_USE_PROTOS -static yy_ste_type yy_try_NUL_trans( register yy_ste_type yy_current_state ) -#else -static yy_ste_type yy_try_NUL_trans( yy_current_state ) -register yy_ste_type yy_current_state; -#endif - - { - register int yy_is_jam; - register YY_CHAR *yy_cp = yy_c_buf_p; - - register YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = yy_def[yy_current_state]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 340); - - return ( yy_is_jam ? 0 : yy_current_state ); - } - - -#ifdef YY_USE_PROTOS -static void yyunput( YY_CHAR c, register YY_CHAR *yy_bp ) -#else -static void yyunput( c, yy_bp ) -YY_CHAR c; -register YY_CHAR *yy_bp; -#endif - - { - register YY_CHAR *yy_cp = yy_c_buf_p; - - /* undo effects of setting up yytext */ - *yy_cp = yy_hold_char; - - if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - register int number_to_move = yy_n_chars + 2; /* +2 for EOB chars */ - register YY_CHAR *dest = - &yy_current_buffer->yy_ch_buf[yy_current_buffer->yy_buf_size + 2]; - register YY_CHAR *source = - &yy_current_buffer->yy_ch_buf[number_to_move]; - - while ( source > yy_current_buffer->yy_ch_buf ) - *--dest = *--source; - - yy_cp += dest - source; - yy_bp += dest - source; - 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" ); - } - - if ( yy_cp > yy_bp && yy_cp[-1] == '\n' ) - yy_cp[-2] = '\n'; - - *--yy_cp = c; - - /* note: the formal parameter *must* be called "yy_bp" for this - * macro to now work correctly - */ - YY_DO_BEFORE_ACTION; /* set up yytext again */ - } - - -#ifdef __cplusplus -static int yyinput() -#else -static int input() -#endif - - { - int c; - YY_CHAR *yy_cp = yy_c_buf_p; - - *yy_cp = yy_hold_char; - - if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) - /* this was really a NUL */ - *yy_c_buf_p = '\0'; - - else - { /* need more input */ - yytext = yy_c_buf_p; - ++yy_c_buf_p; - - switch ( yy_get_next_buffer() ) - { - case EOB_ACT_END_OF_FILE: - { - if ( yywrap() ) - { - yy_c_buf_p = yytext + YY_MORE_ADJ; - return ( EOF ); - } - - YY_NEW_FILE; - -#ifdef __cplusplus - return ( yyinput() ); -#else - return ( input() ); -#endif - } - break; - - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = yytext + YY_MORE_ADJ; - 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 - } - } - } - - c = *yy_c_buf_p; - yy_hold_char = *++yy_c_buf_p; - - return ( c ); - } - - -#ifdef YY_USE_PROTOS -void yyrestrt( FILE *input_file ) -#else -void yyrestrt( input_file ) -FILE *input_file; -#endif - - { - yyinbffr( yy_current_buffer, input_file ); - yyldbfst(); - } - - -#ifdef YY_USE_PROTOS -void yyswtobf( YY_BUFFER_STATE new_buffer ) -#else -void yyswtobf( new_buffer ) -YY_BUFFER_STATE new_buffer; -#endif - - { - if ( yy_current_buffer == new_buffer ) - return; - - if ( yy_current_buffer ) - { - /* flush out information for old buffer */ - *yy_c_buf_p = yy_hold_char; - yy_current_buffer->yy_buf_pos = yy_c_buf_p; - yy_current_buffer->yy_n_chars = yy_n_chars; - } - - yy_current_buffer = new_buffer; - yyldbfst(); - - /* we don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - yy_did_buffer_switch_on_eof = 1; - } - - -#ifdef YY_USE_PROTOS -void yyldbfst( void ) -#else -void yyldbfst() -#endif - - { - yy_n_chars = yy_current_buffer->yy_n_chars; - yytext = yy_c_buf_p = yy_current_buffer->yy_buf_pos; - yyin = yy_current_buffer->yy_input_file; - yy_hold_char = *yy_c_buf_p; - } - - -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yycrbffr( FILE *file, int size ) -#else -YY_BUFFER_STATE yycrbffr( file, size ) -FILE *file; -int size; -#endif - - { - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) malloc( sizeof( struct yy_buffer_state ) ); - - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yycrbffr()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (YY_CHAR *) malloc( (unsigned) (b->yy_buf_size + 2) ); - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yycrbffr()" ); - - yyinbffr( b, file ); - - return ( b ); - } - - -#ifdef YY_USE_PROTOS -void yydlbffr( YY_BUFFER_STATE b ) -#else -void yydlbffr( b ) -YY_BUFFER_STATE b; -#endif - - { - if ( b == yy_current_buffer ) - yy_current_buffer = (YY_BUFFER_STATE) 0; - - free( (char *) b->yy_ch_buf ); - free( (char *) b ); - } - - -#ifdef YY_USE_PROTOS -void yyinbffr( YY_BUFFER_STATE b, FILE *file ) -#else -void yyinbffr( b, file ) -YY_BUFFER_STATE b; -FILE *file; -#endif - - { - b->yy_input_file = file; - - /* we put in the '\n' and start reading from [1] so that an - * initial match-at-newline will be true. - */ - - b->yy_ch_buf[0] = '\n'; - b->yy_n_chars = 1; - - /* we always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[2] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[1]; - - b->yy_eof_status = EOF_NOT_SEEN; - } -# line 496 "" - - - -int yywrap() - - { - if ( --ninfiles > 0 ) - { - stinpfle( *++inp_fles ); - return ( 0 ); - } - - else - return ( 1 ); - } - - -/* stinpfle - open the given file (if NULL, stdin) for scanning */ - -void stinpfle( file ) -char *file; - - { - if ( file ) - { - infilnam = file; - yyin = fopen( infilnam, "r" ); - - if ( yyin == NULL ) - lerrsf( "can't open %s", file ); - } - - else - { - yyin = stdin; - infilnam = ""; - } - } diff --git a/commands/flex-2.5.4/MISC/MVS/unfixit.l b/commands/flex-2.5.4/MISC/MVS/unfixit.l deleted file mode 100644 index 3f8dddc68..000000000 --- a/commands/flex-2.5.4/MISC/MVS/unfixit.l +++ /dev/null @@ -1,141 +0,0 @@ -%{ -/* unfixit.l - convert shortened external names to names back to their - * original names. (See fixit.l) - */ - -/* - * This program is included to satisfy "dumb" compilers/linkers which - * do not know about externals of names longer than 8 bytes. - * - * Steven W. Layten - * Chemical Abstracts Service - * PO BOX 3012 - * Columbus, OH 43210 - */ -%} -%% -"actfilnm" printf("action_file_name"); -"actnout" printf("action_out"); -"addacpt" printf("add_accept"); -"alllower" printf("all_lower"); -"allupper" printf("all_upper"); -"allocarr" printf("allocate_array"); -"asscrule" printf("assoc_rule"); -"bktrkfil" printf("backtrack_file"); -"bktrkrep" printf("backtrack_report"); -"bol_nded" printf("bol_needed"); -"bldeofac" printf("build_eof_action"); -"cclnstal" printf("cclinstal"); -"ccllookp" printf("ccllookup"); -"cclnegat" printf("cclnegate"); -"cclsrted" printf("cclsorted"); -"ck4bktrk" printf("check_for_backtracking"); -"cktrlcnt" printf("check_trailing_context"); -"cntdactn" printf("continued_action"); -"copystrn" printf("copy_string"); -"cpunsstr" printf("copy_unsigned_string"); -"cpyrght" printf("copyright"); -"copysngl" printf("copysingl"); -"c_mx_ccl" printf("current_max_ccl_tbl_size"); -"c_mx_dfa" printf("current_max_dfa_size"); -"c_mxdfas" printf("current_max_dfas"); -"curmxrls" printf("current_max_rules"); -"c_mx_scs" printf("current_max_scs"); -"c_mx_tmp" printf("current_max_template_xpairs"); -"c_mx_xpr" printf("current_max_xpairs"); -"c_mxccls" printf("current_maxccls"); -"curr_mns" printf("current_mns"); -"cursttyp" printf("current_state_type"); -"datflush" printf("dataflush"); -"dfacunin" printf("dfaacc_union"); -"do_indnt" printf("do_indent"); -"dmpasrl" printf("dump_associated_rules"); -"dmptrns" printf("dump_transitions"); -"dupmach" printf("dupmachine"); -"ecsfrmxt" printf("ecs_from_xlation"); -"eobstate" printf("end_of_buffer_state"); -"epsclos" printf("epsclosure"); -"expnxtck" printf("expand_nxt_chk"); -"fndtblsp" printf("find_table_space"); -"fnshrule" printf("finish_rule"); -"firstfre" printf("firstfree"); -"firstprt" printf("firstprot"); -"flxgettm" printf("flex_gettime"); -"flxerror" printf("flexerror"); -"flxfatal" printf("flexfatal"); -"fmtptmsg" printf("format_pinpoint_message"); -"gnNULtrn" printf("gen_NUL_trans"); -"gnbktrkg" printf("gen_backtracking"); -"gnbtactn" printf("gen_bt_action"); -"gnfndact" printf("gen_find_action"); -"gnlindir" printf("gen_line_dirs"); -"gnnxcste" printf("gen_next_compressed_state"); -"gnnxmtch" printf("gen_next_match"); -"gnnxtst" printf("gen_next_state"); -"gnstrtst" printf("gen_start_state"); -"hshentry" printf("hash_entry"); -"hshfct" printf("hashfunct"); -"incmxdfa" printf("increase_max_dfas"); -"indput2s" printf("indent_put2s"); -"indputs" printf("indent_puts"); -"infilnam" printf("infilename"); -"inp_fles" printf("input_files"); -"intractv" printf("interactive"); -"lndirout" printf("line_directive_out"); -"lnkmchns" printf("link_machines"); -"lst_cset" printf("list_character_set"); -"maketbls" printf("make_tables"); -"mkbgnorm" printf("mark_beginning_as_normal"); -"mktmplat" printf("mktemplate"); -"nbktrckg" printf("num_backtracking"); -"ninfiles" printf("num_input_files"); -"numraloc" printf("num_reallocs"); -"numrules" printf("num_rules"); -"nuxlatns" printf("num_xlations"); -"numnpair" printf("numsnpairs"); -"outfilnm" printf("output_file_name"); -"peakpair" printf("peakpairs"); -"perf_rep" printf("performance_report"); -"pptmsg" printf("pinpoint_message"); -"plcstate" printf("place_state"); -"prvctdan" printf("previous_continued_action"); -"prtstats" printf("printstats"); -"pgm_name" printf("program_name"); -"prtcomst" printf("protcomst"); -"rdblefrm" printf("readable_form"); -"realrjct" printf("real_reject"); -"rallocar" printf("reallocate_array"); -"rjctused" printf("reject_really_used"); -"rulelnno" printf("rule_linenum"); -"ruletype" printf("rule_type"); -"stinpfle" printf("set_input_file"); -"setupia" printf("set_up_initial_allocations"); -"startime" printf("starttime"); -"ste_type" printf("state_type"); -"symfollo" printf("symfollowset"); -"sympartn" printf("sympartition"); -"syntxerr" printf("syntaxerror"); -"tmpactfl" printf("temp_action_file"); -"todohead" printf("todo_head"); -"todonext" printf("todo_next"); -"trnschar" printf("transchar"); -"trnstout" printf("transition_struct_out"); -"trlcntxt" printf("trlcontxt"); -"vtrailrl" printf("variable_trail_rule"); -"vtrlctrl" printf("variable_trailing_context_rules"); -"varlngth" printf("varlength"); -"yycrbffr" printf("yy_create_buffer"); -"yydlbffr" printf("yy_delete_buffer"); -"yyinbffr" printf("yy_init_buffer"); -"yyldbfst" printf("yy_load_buffer_state"); -"yyswtobf" printf("yy_switch_to_buffer"); -"yyerrflg" printf("yyerrflag"); -"yymrreus" printf("yymore_really_used"); -"yymrused" printf("yymore_used"); -"yyrestrt" printf("yyrestart"); -. ECHO; -%% -main() -{ - yylex(); -} diff --git a/commands/flex-2.5.4/MISC/Macintosh/THINK_C_notes b/commands/flex-2.5.4/MISC/Macintosh/THINK_C_notes deleted file mode 100644 index e99c97227..000000000 --- a/commands/flex-2.5.4/MISC/Macintosh/THINK_C_notes +++ /dev/null @@ -1,100 +0,0 @@ -Notes on the THINK C version of Flex 2.4.6 -Scott Hofmann 23-JUL-94 -Internet: scotth@visix.com - -The only changes needed to compile Flex 2.4.6 under Symantec C++ 6.0 was -to #include in main.c and call ccommand() just before flexinit() -in main(). The notes below are mostly of historical significance only; most -of the workarounds below were to get around restrictions/problems in earlier -versions of THINK C. The only section which still applies is Russell Finn's -description of how to make Flex generate output of type 'KAHL'. Also, 4-byte -ints must be used by any project which uses Flex output. - -If you want to recreate the project, you'll need to add the files -alloca.c and xmalloc.c in this directory. Both files are copylefted; see -the GNU General Public License for details. You will also need to recompile -both the ANSI and unix libraries to use 4 byte ints, and if you want the -files that flex creates to have 'KAHL' as the creator you'll need to apply -Russell Finn's patch. - -Notes on the THINK C version of Flex 2.3.7 -Jonas Barklund, 25-JAN-92 -Internet: jonas@csd.uu.se - -I have merged the sources for Flex version 2.3.7 with the older version -which was hacked for THINK C version 4. I have conditionalized the code -so that I think it should work with both THINK C version 4 and 5 (for -those of you who don't know: the THINK_C symbol is defined as 1 in version -4 and as 5 in version 5). I have put in some missing prototypes, so it -compiles also with "require prototypes" on. - -Most of the notes below still apply, in particular that about the MakeRes -program. - - -Notes on the THINK C version of Flex -Russell S. Finn, 19-FEB-90 -Internet: rsfinn@athena.mit.edu, rsfinn@neutron.lcs.mit.edu -CompuServe: 76377,1107 -GEnie: RSFINN - -Flex appears to be covered by a copyright notice from the University of -California, similar to the one covering Berkeley Unix; the Free Software -Foundation is not part of the picture here. So here is a version -created with THINK C 4.0, along with the source code; as with the -Bison distribution, I am including *all* of the source code I received -with the package. - -The current version (modification date January 25, 1990) has only the -bare-bones interface provided by the THINK C library routine "ccommand", -which allows the user to type a command line and to redirect the output. -Perhaps someday I may try to implement a "real" user interface; perhaps -not. - -The only modifications made to the source file are surrounded by "#ifdef -THINK_C"..."#endif"; in theory, then, these sources could be recompiled -on another system if necessary. These are the actual files modified: -alloca.c, dfa.c, flexdef.h, main.c, misc.c, scan.c, sym.c. Most of these -changes were minor, and many of them would have been unnecessary if the -original Flex source code had been written for an ANSI-compliant C compiler. -In addition, the file "macutils.c" is completely new; see the discussion -of "MakeRes" below. - -THINK C users may find it convenient to have the output text files written -by Flex be THINK C documents. To do this, create a copy of the "ANSI" -project called "ANSI-KAHL", and a copy of the file "fopen.c" called -"fopen-KAHL.c". In the copy, find the routine "setfiletype", and replace -the lines: - if (!(oflag & F_BINARY)) - pb.ioFlFndrInfo.fdType = 'TEXT'; -with the lines: - if (!(oflag & F_BINARY)) { - pb.ioFlFndrInfo.fdType = 'TEXT'; - pb.ioFlFndrInfo.fdCreator = 'KAHL'; - } -Replace "fopen.c" with the new "fopen-KAHL.c", rebuild the new project -"ANSI-KAHL", and use this project in the project file "Flex.¹" -instead of the "ANSI" project. - -** The "MakeRes" program - -The output files created by Flex contain large amounts of preinitialized -static data; the file "scan.c" contained in the Flex.¹ project is one -such file. However, the Macintosh architecture limits normal applications -to 32K of global data. In many cases (including Flex), this limit can -be surpassed by the static data generated by Flex. - -The solution I have implemented for the THINK C version of Flex is to -extract the data tables from the Flex output file, and paste them into -the file "MakeRes.c". Then, by recompiling and running the program in -the "MakeRes.¹" project (it is not necessary to create an application), -a resource file called "Flex.¹.rsrc" is created in the current directory. -The Flex output file "scan.c" has been modified to load the static data -from the resource fork of the Flex application. This is done by calling -the "load_table" function, which is defined in the file "macutils.c". - -In the application for which I needed Flex, the data tables were small -enough that I didn't need to do this. However, if your application -requires you to do this, simply follow the model of "scan.c"; the MakeRes -project and source code has been included for your use. - diff --git a/commands/flex-2.5.4/MISC/Macintosh/alloca.c b/commands/flex-2.5.4/MISC/Macintosh/alloca.c deleted file mode 100644 index 9cb6fa036..000000000 --- a/commands/flex-2.5.4/MISC/Macintosh/alloca.c +++ /dev/null @@ -1,195 +0,0 @@ -/* - alloca -- (mostly) portable public-domain implementation -- D A Gwyn - - last edit: 86/05/30 rms - include config.h, since on VMS it renames some symbols. - Use xmalloc instead of malloc. - - This implementation of the PWB library alloca() function, - which is used to allocate space off the run-time stack so - that it is automatically reclaimed upon procedure exit, - was inspired by discussions with J. Q. Johnson of Cornell. - - It should work under any C implementation that uses an - actual procedure stack (as opposed to a linked list of - frames). There are some preprocessor constants that can - be defined when compiling for your specific system, for - improved efficiency; however, the defaults should be okay. - - The general concept of this implementation is to keep - track of all alloca()-allocated blocks, and reclaim any - that are found to be deeper in the stack than the current - invocation. This heuristic does not reclaim storage as - soon as it becomes invalid, but it will do so eventually. - - As a special case, alloca(0) reclaims storage without - allocating any. It is a good idea to use alloca(0) in - your main control loop, etc. to force garbage collection. -*/ -#ifndef lint -static char SCCSid[] = "@(#)alloca.c 1.1"; /* for the "what" utility */ -#endif - -#ifdef emacs -#include "config.h" -#ifdef static -/* actually, only want this if static is defined as "" - -- this is for usg, in which emacs must undefine static - in order to make unexec workable - */ -#ifndef STACK_DIRECTION -you -lose --- must know STACK_DIRECTION at compile-time -#endif /* STACK_DIRECTION undefined */ -#endif /* static */ -#endif /* emacs */ - -#ifndef alloca /* If compiling with GCC, this file's not needed. */ - -#ifdef __STDC__ -typedef void *pointer; /* generic pointer type */ -#else -typedef char *pointer; /* generic pointer type */ -#endif - -#define NULL 0 /* null pointer constant */ - -extern void free(); -extern pointer xmalloc(); - -/* - Define STACK_DIRECTION if you know the direction of stack - growth for your system; otherwise it will be automatically - deduced at run-time. - - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown -*/ - -#ifndef STACK_DIRECTION -#define STACK_DIRECTION 0 /* direction unknown */ -#endif - -#if STACK_DIRECTION != 0 - -#define STACK_DIR STACK_DIRECTION /* known at compile-time */ - -#else /* STACK_DIRECTION == 0; need run-time code */ - -static int stack_dir; /* 1 or -1 once known */ -#define STACK_DIR stack_dir - -static void -find_stack_direction (/* void */) -{ - static char *addr = NULL; /* address of first - `dummy', once known */ - auto char dummy; /* to get stack address */ - - if (addr == NULL) - { /* initial entry */ - addr = &dummy; - - find_stack_direction (); /* recurse once */ - } - else /* second entry */ - if (&dummy > addr) - stack_dir = 1; /* stack grew upward */ - else - stack_dir = -1; /* stack grew downward */ -} - -#endif /* STACK_DIRECTION == 0 */ - -/* - An "alloca header" is used to: - (a) chain together all alloca()ed blocks; - (b) keep track of stack depth. - - It is very important that sizeof(header) agree with malloc() - alignment chunk size. The following default should work okay. -*/ - -#ifndef ALIGN_SIZE -#define ALIGN_SIZE sizeof(double) -#endif - -typedef union hdr -{ - char align[ALIGN_SIZE]; /* to force sizeof(header) */ - struct - { - union hdr *next; /* for chaining headers */ - char *deep; /* for stack depth measure */ - } h; -} header; - -/* - alloca( size ) returns a pointer to at least `size' bytes of - storage which will be automatically reclaimed upon exit from - the procedure that called alloca(). Originally, this space - was supposed to be taken from the current stack frame of the - caller, but that method cannot be made to work for some - implementations of C, for example under Gould's UTX/32. -*/ - -static header *last_alloca_header = NULL; /* -> last alloca header */ - -pointer -alloca (size) /* returns pointer to storage */ - unsigned size; /* # bytes to allocate */ -{ - auto char probe; /* probes stack depth: */ - register char *depth = &probe; - -#if STACK_DIRECTION == 0 - if (STACK_DIR == 0) /* unknown growth direction */ - find_stack_direction (); -#endif - - /* Reclaim garbage, defined as all alloca()ed storage that - was allocated from deeper in the stack than currently. */ - - { - register header *hp; /* traverses linked list */ - - for (hp = last_alloca_header; hp != NULL;) - if ((STACK_DIR > 0 && hp->h.deep > depth) - || (STACK_DIR < 0 && hp->h.deep < depth)) - { - register header *np = hp->h.next; - - free ((pointer) hp); /* collect garbage */ - - hp = np; /* -> next header */ - } - else - break; /* rest are not deeper */ - - last_alloca_header = hp; /* -> last valid storage */ - } - - if (size == 0) - return NULL; /* no allocation required */ - - /* Allocate combined header + user data storage. */ - - { - register pointer new = xmalloc (sizeof (header) + size); - - /* address of header */ - - ((header *)new)->h.next = last_alloca_header; - ((header *)new)->h.deep = depth; - - last_alloca_header = (header *)new; - - /* User storage begins just after header. */ - - return (pointer)((char *)new + sizeof(header)); - } -} - -#endif /* no alloca */ diff --git a/commands/flex-2.5.4/MISC/Macintosh/alloca.h b/commands/flex-2.5.4/MISC/Macintosh/alloca.h deleted file mode 100644 index f48eaf2f7..000000000 --- a/commands/flex-2.5.4/MISC/Macintosh/alloca.h +++ /dev/null @@ -1,10 +0,0 @@ -/**************** -** alloca.h -** -** header for alloca() -*****************/ - -typedef void *pointer; - -pointer alloca(unsigned size); - diff --git a/commands/flex-2.5.4/MISC/Macintosh/xmalloc.c b/commands/flex-2.5.4/MISC/Macintosh/xmalloc.c deleted file mode 100644 index 5bef83197..000000000 --- a/commands/flex-2.5.4/MISC/Macintosh/xmalloc.c +++ /dev/null @@ -1,69 +0,0 @@ -/* xmalloc.c -- malloc with out of memory checking - Copyright (C) 1990, 1991 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#if STDC_HEADERS || THINK_C -#include -#else -char *malloc (); -char *realloc (); -void free (); -#endif - -#ifdef THINK_C -#define error(x, y, z) perror(z) /* Throw out meaningless arguments */ -#else -void error (); -#endif - -/* Allocate N bytes of memory dynamically, with error checking. */ - -char * -xmalloc (n) - unsigned n; -{ - char *p; - - p = malloc (n); - if (p == 0) - /* Must exit with 2 for `cmp'. */ - error (2, 0, "virtual memory exhausted"); - return p; -} - -/* Change the size of an allocated block of memory P to N bytes, - with error checking. - If P is NULL, run xmalloc. - If N is 0, run free and return NULL. */ - -char * -xrealloc (p, n) - char *p; - unsigned n; -{ - if (p == 0) - return xmalloc (n); - if (n == 0) - { - free (p); - return 0; - } - p = realloc (p, n); - if (p == 0) - /* Must exit with 2 for `cmp'. */ - error (2, 0, "virtual memory exhausted"); - return p; -} diff --git a/commands/flex-2.5.4/MISC/NT/Makefile b/commands/flex-2.5.4/MISC/NT/Makefile deleted file mode 100644 index 581d49778..000000000 --- a/commands/flex-2.5.4/MISC/NT/Makefile +++ /dev/null @@ -1,103 +0,0 @@ -# -# make file for "flex" tool -# @(#) $Header: /usr/fsys/odin/a/vern/flex/RCS/Makefile,v 2.9 -# 90/05/26 17:28:44 vern Exp $ (LBL) -# -# the first time around use "nmake f_flex" -# -# This makefile is specific for Microsoft's Visual C 2.0, & nmake -# -# - Stan Adermann -# - - -SKELFLAGS = -DDEFAULT_SKELETON_FILE=\"c:/src/flex/flex.skl\" -CFLAGS = -nologo -W2 -F 8000 -Ox -DUSG -LDFLAGS = /nologo /BATCH /STACK:8000 -FLEX_FLAGS = -ist8 -Sflex.skl - -FLEX = .\flex.exe -CC = cl -YACC = c:\lib\byacc -MAKE = nmake /nologo - -FLEXOBJS = \ - ccl.obj \ - dfa.obj \ - ecs.obj \ - gen.obj \ - main.obj \ - misc.obj \ - nfa.obj \ - parse.obj \ - scan.obj \ - skel.obj \ - sym.obj \ - tblcmp.obj \ - yylex.obj - -FLEX_C_SOURCES = \ - ccl.c \ - dfa.c \ - ecs.c \ - gen.c \ - main.c \ - misc.c \ - nfa.c \ - parse.c \ - scan.c \ - skel.c \ - sym.c \ - tblcmp.c \ - yylex.c - -all : flex.exe - -flex.exe : $(FLEXOBJS) - link $(LDFLAGS) $(FLEXOBJS) -out:$*.exe - -f_flex: - copy initscan.c scan.c - touch scan.c - @echo compiling first flex - $(MAKE) flex.exe - del scan.c - @echo using first flex to generate final version... - $(MAKE) flex.exe - -# -# general inference rule -# -.c.obj: - $(CC) -c $(CFLAGS) $*.c - -parse.h parse.c : parse.y - $(YACC) -d parse.y - @move y_tab.c parse.c - @move y_tab.h parse.h - -scan.c : scan.l - $(FLEX) $(FLEX_FLAGS) $(COMPRESSION) scan.l >scan.c - - -scan.obj : scan.c parse.h flexdef.h - -main.obj : main.c flexdef.h - $(CC) $(CFLAGS) -c $(SKELFLAGS) main.c - -ccl.obj : ccl.c flexdef.h -dfa.obj : dfa.c flexdef.h -ecs.obj : ecs.c flexdef.h -gen.obj : gen.c flexdef.h -misc.obj : misc.c flexdef.h -nfa.obj : nfa.c flexdef.h -parse.obj : parse.c flexdef.h -sym.obj : sym.c flexdef.h -tblcmp.obj : tblcmp.c flexdef.h -yylex.obj : yylex.c flexdef.h -skel.obj : skel.c flexdef.h - - -clean : - del *.obj - del *.map diff --git a/commands/flex-2.5.4/MISC/NeXT b/commands/flex-2.5.4/MISC/NeXT deleted file mode 100644 index f862a1f43..000000000 --- a/commands/flex-2.5.4/MISC/NeXT +++ /dev/null @@ -1,34 +0,0 @@ -this API is not documented/supported by NeXT and may go away at any time, - so test again when you upgrade (works fine for me on NEXTSTEP_Dev_3.2) -------------------------------------------------------------------------- -See KBNS.32.2.029 from the successor of: -ftp://ftp.cs.orst.edu/software/NeXT/documents/KBNS.32.1.rtf -Otherwise (that successor not yet having been published), ask me for a copy -of the item on RfSchtkt@maze.ruca.ua.ac.be. Bison's messages are not as -disciplined as flex' ones, so it should get more discipline first. - -Specifically (in addition to what's described in the KBNS item): -makeUser.o and make_support.o should be added to OBJECTS in Makefile.in -In parse.y, line_pinpoint() (assumption all messages ultimately go there), add: - make_support( - // don't worry about declaring: cc's source doesn't either, - // it seems - syntaxerror?0:1, - NULL, - infilename, - line, - str, - 0,0,0 - ); - -FMyIO: in cc, these files contain the word make_support: - ChangeLog-NeXT - Makefile.in - config/next.h: defines REPORT_EVENT in terms of make_support - make_support.c - -FMyIO: in cc, these files contain the word REPORT_EVENT: - cccp.c - config/next.h - gcc.c - toplev.c diff --git a/commands/flex-2.5.4/MISC/OS2/Makefile.os2 b/commands/flex-2.5.4/MISC/OS2/Makefile.os2 deleted file mode 100644 index e984f6de2..000000000 --- a/commands/flex-2.5.4/MISC/OS2/Makefile.os2 +++ /dev/null @@ -1,72 +0,0 @@ -# make file for "flex" tool, emx+gcc - -release: - $(MAKE) -f Makefile.os2 flex.exe \ - CC="gcc -Zomf -O" O=".obj" A=".lib" AR="emxomfar" \ - LDFLAGS="-s -Zcrtdll -Zstack 512" -debug: - $(MAKE) -f Makefile.os2 flex.exe \ - CC="gcc -g" O=".o" A=".a" AR="ar" - -CFLAGS = -DOS2 -DSHORT_FILE_NAMES - -YACC = bison -FLEX = flex -FLEX_FLAGS = -ist - -.SUFFIXES: .c $O - -.c$O: - $(CC) $(CFLAGS) -c $< - -FLEXLIB = fl$A -FLEXOBJS = ccl$O dfa$O ecs$O gen$O main$O misc$O nfa$O parse$O \ - scan$O skel$O sym$O tblcmp$O yylex$O -LIBOBJS = libmain$O libyywrap$O - -flex.exe : $(FLEXOBJS) $(FLEXLIB) - $(CC) $(LDFLAGS) -o $@ $(FLEXOBJS) $(FLEXLIB) - -first_flex: - cp initscan.c scan.c - $(MAKE) $(MFLAGS) flex - -$(FLEXLIB): $(LIBOBJS) - $(AR) cru $(FLEXLIB) $(LIBOBJS) - $(AR) s $(FLEXLIB) - -parse.h parse.c: parse.y - $(YACC) -d -o parse.c parse.y - -scan.c : scan.l - $(FLEX) $(FLEX_FLAGS) $(COMPRESSION) scan.l >scan.c - -scan$O : scan.c parse.h flexdef.h - -main$O : main.c flexdef.h -ccl$O : ccl.c flexdef.h -dfa$O : dfa.c flexdef.h -ecs$O : ecs.c flexdef.h -gen$O : gen.c flexdef.h -misc$O : misc.c flexdef.h -nfa$O : nfa.c flexdef.h -parse$O : parse.c flexdef.h -sym$O : sym.c flexdef.h -tblcmp$O : tblcmp.c flexdef.h -yylex$O : yylex.c flexdef.h - -skel.c: flex.skl mkskel.sh - $(SHELL) mkskel.sh flex.skl >skel.c - -test : flex - flex $(FLEX_FLAGS) $(COMPRESSION) scan.l | diff scan.c - - -bigtest : - rm -f scan.c ; $(MAKE) COMPRESSION="-C" test - rm -f scan.c ; $(MAKE) COMPRESSION="-Ce" test - rm -f scan.c ; $(MAKE) COMPRESSION="-Cm" test - rm -f scan.c ; $(MAKE) COMPRESSION="-Cfe" test - rm -f scan.c ; $(MAKE) COMPRESSION="-CFe" test - rm -f scan.c ; $(MAKE) COMPRESSION="-Cf" test - rm -f scan.c ; $(MAKE) COMPRESSION="-CF" test - rm -f scan.c ; $(MAKE) diff --git a/commands/flex-2.5.4/MISC/OS2/config.h b/commands/flex-2.5.4/MISC/OS2/config.h deleted file mode 100644 index acf7b8637..000000000 --- a/commands/flex-2.5.4/MISC/OS2/config.h +++ /dev/null @@ -1,28 +0,0 @@ -/* ------------------------------------------------ */ -/* version of config.h for OS/2 */ -/* ------------------------------------------------ */ - -/* Define to empty if the keyword does not work. */ -#undef const - -/* Define to `unsigned' if doesn't define. */ -#undef size_t - -/* Define if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define if you have the header file. */ -#define HAVE_MALLOC_H 1 - -/* Define if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define if you have and it should be used (not on Ultrix). */ -#define HAVE_ALLOCA_H - -/* Define if platform-specific command line handling is necessary. */ -#define NEED_ARGV_FIXUP -#define argv_fixup(ac,av) { _response(ac,av); _wildcard(ac,av);} diff --git a/commands/flex-2.5.4/MISC/README b/commands/flex-2.5.4/MISC/README deleted file mode 100644 index dc16b0233..000000000 --- a/commands/flex-2.5.4/MISC/README +++ /dev/null @@ -1,76 +0,0 @@ -Miscellaneous flex stuff. The items which have been tested with flex 2.5 are: - - - texinfo/, a subdirectory containing a "texinfo" version of flex(1) - and the corresponding "info" files (contributed by Francois Pinard). - - - VMS/, a subdirectory containing makefiles, configuration files, - run-time support, and installation notes for building flex 2.5 - on VMS (contributed by Pat Rankin). - - - Borland/ - makefile and config.h for Borland 4.02 compiler - (contributed by Terrence O Kane, who notes that no source - code changes were necessary). - - - NT/ - Makefile and config.h for NT, contributed by Stan Adermann. - - - OS2/ - Makefile and config.h for building flex under OS/2, - contributed by Kai Uwe Rommel. - - - Amiga/: notes on building flex for the Amiga, contributed - by Andreas Scherer. - - - parse.c, parse.h - output of running yacc (byacc, actually) - on parse.y. If your system doesn't have a flavor of yacc available, - copy these into the main flex source directory instead. - - - flex.man - preformatted version of flex man page - - -The following have been tested using flex 2.4: - - - debflex.awk, an awk script for anotating flex debug output. - It presently only works with gawk and mawk, not with "old" - or "new" awk. - - - NeXT: ProjectBuilder.app support for use in the NeXT world. - - - Notes on building flex for the Macintosh using Think-C, - in the Macintosh/ subdirectory. - - - testxxLexer.l, a sample C++ program that uses flex's scanner - class option ("-+"). - - - fastwc/, a subdirectory containing examples of how to use flex - to write progressively higher-performance versions of the Unix - "wc" utility. This certainly should work with 2.5, but hasn't - been tested. - - - Borland.old/: notes on building flex 2.4 for Borland C++ 3.1 - on MS-DOS. These shouldn't be needed for flex 2.5. Included - only in case you encounter unanticipated difficulties. - - - EBCDIC: contact information for building flex for EBCDIC. - - -The following are all out-of-date with respect to flex release 2.4 (and -in general up-to-date for flex 2.3): - - - Atari/Atari.patches, patches for porting flex to the Atari and - to Minix. - - - A number of notes and Makefiles for compiling flex under MS-DOS, - in the MSDOS/ subdirectory. - - - Notes on building flex for MVS, in the MVS/ subdirectory. - -If any of this is out-of-date and can be deleted, please let me know. - -And the following is included for compatibility with some broken versions -of bison: - - - alloca.c, a public-domain, mostly-portable version of the - alloca() routine (used by bison's parsers) written by D. A. Gwyn. - - -Many thanks to those who contributed these files. Updated versions will -be appreciated! diff --git a/commands/flex-2.5.4/MISC/VMS/README.VMS b/commands/flex-2.5.4/MISC/VMS/README.VMS deleted file mode 100644 index e4a49660c..000000000 --- a/commands/flex-2.5.4/MISC/VMS/README.VMS +++ /dev/null @@ -1,83 +0,0 @@ -Brief instructions for building flex 2.5.x for VMS: - - 0) if you have either MMS (from Digital) or MMK (freeware) for use -as a `make' utility, follow the directions in steps #1 through #5 below. -If not, execute - @BUILD.COM xxxC -where "xxxC" is either "VAXC" or "DECC" or "GNUC", and then skip to -step #5. - - 1) set default to the source directory (not the [.MISC.VMS] subdirectory -where this file is located). - - 2) COPY [.MISC.VMS]DESCRIP.MMS []*.* -(Recursive invocations of `make' for the `bigcheck' test assume that the -makefile will be found as descrip.mms in the current directory.) - -To build with VAX C for VAX/VMS: - 3) MMS /MACRO=("VAXC=1") FLEX.EXE -(The /macro qualifier is optional in this case.) - -To build with GNU C for VAX/VMS: - 2.5) possibly edit descrip.mms to uncomment `SET COMMAND' for GCCINIT, - depending on local site configuration - 3) MMS /MACRO=("GNUC=1") FLEX.EXE - -To build with DEC C for either VAX/VMS or Alpha/VMS: - 3) MMS /MACRO=("DECC=1") FLEX.EXE -(Expect one or two informational messages from the compiler about -implicitly declared functions.) - -Minimal testing of the resulting program: - 4) MMS CHECK -(If `diff' reports no warnings, the test has succeeded.) - -More thorough testing: - 4.5) MMS /MACRO=("xxxC=1") BIGCHECK ! "xxxC=1" as in step #3 above -(If using an older version of MMK rather than MMS, this might fail when -`make' is invoked recursively due to excessive BYTLM usage by MMK.) - -Installation (the VMS makefile does not support an `install' target; -you'll need to do this part manually): - 5) copy flex.exe, flex.doc, flex.skl, flexlib.olb, and FlexLexer.h to -location(s) appropriate for your site. To use flex, define a "foreign" -command by making a DCL symbol whose value begins with a dollar sign -immediately followed by the filename for flex.exe, as in - $ flex :== $local_tools:flex.exe -where `local_tools:' is the logical name pointing to flex.exe's location. -This symbol will ordinarily be a candidate for your login.com. When -invoking flex, upper- or mixed-case command line options must be enclosed -in quotes. For example, - $ flex "-Pxyz" "-L" -t mylexer.l > mylexer.c -(use prefix "xyz" instead of "yy", suppress `#line' compiler directives -in the output, write the output to `stdout', process file mylexer.l, -and capture `stdout' in file mylexer.c). As illustrated here, this VMS -version of flex supports emulation of command line I/O redirection used -by Unix shells. - - flex.exe -- the executable image for the flex program; - flex.doc -- documentation, the "man page" describing flex (flex.1 - processed with `nroff -man' followed by `col -b'); - flex.skl -- a text file containing flex's default skeleton; - with this version of flex, it is for reference only; - flex.exe does not need to know where to find it; - flexlib.olb -- an object library containing some support routines; - you might need to link your generated lexer against - it, depending on how your program is designed; - flex.exe does not access it; it corresponds to - `libfl.a' under Unix; - FlexLexer.h -- header file used for C++ class-based lexers; not - needed for ordinary C lexers. - -Notes: - This VMS port of flex supports only the original Unix command line -interface, not the native DCL interface which was available for flex 2.3. - - build.com -- DCL command procedure as alternative to descrip.mms; - descrip.mms -- 2.5.x makefile for use with MMS or MMK (see step #1); - mkskel.tpu -- TPU program used to make skel.c from flex.skl for full - build from scratch; performs same function as mkskel.sh; - vms-conf.h -- pre-configured `conf.in', copied to [-.-]config.h; - vms-code.c -- VMS-specific support code, copied to [-.-]vms-code.c; - README.VMS -- this file - diff --git a/commands/flex-2.5.4/MISC/VMS/build.com b/commands/flex-2.5.4/MISC/VMS/build.com deleted file mode 100644 index dbde55ab0..000000000 --- a/commands/flex-2.5.4/MISC/VMS/build.com +++ /dev/null @@ -1,155 +0,0 @@ -$! VMS build procedure for flex 2.5.x; -$ v = 'f$verify(0)' -$! -$! usage: -$! $ @[.MISC.VMS]BUILD.COM compiler parser [test] -$! where `compiler' is either "GNUC" or "DECC" or "VAXC" or empty -$! and `parser' is either "BISON" or "BYACC" or "YACC" or empty -$! and `[test]' is either "CHECK-ONLY" or "NO-CHECK" or empty -$! empty compiler defaults to VAX C (even under Alpha/VMS); -$! special "LINK" compiler value does link without compilation; -$! empty parser defaults to using supplied parse code in [.MISC]; -$! optional test is performed by default. -$! -$ -$! we start from [.MISC.VMS], then move to the main source directory -$ where = f$parse("_._;",f$environ("PROCEDURE")) - "_._;" -$ set default 'where' -$ brkt = f$extract(f$length(where)-1,1,where) -$ if f$locate(".MISC.VMS"+brkt,where).lt.f$length(where) then - - set default 'f$string(f$extract(0,1,f$dir()) + "-.-" + brkt)' -$ -$ p1 := 'p1' -$ p2 := 'p2' -$ p3 := 'p3' -$ if p1.eqs."LINK" then goto link -$ if p3.eqs."CHECK-ONLY" then goto check -$ p2 = p2 - "_PARSER" -$! -$ CDEFS = "/Define=(""VMS"")" ! =(""VMS"",""DEFAULT_CSIZE=256"") -$! -$ if p1.eqs."GNUC" -$ then CC = "gcc" -$ CFLAGS = "/noList/Opt=2/Debug/noVerbose" -$ LIBS = "gnu_cc:[000000]gcclib.olb/Library, sys$library:vaxcrtl.olb/Library" -$ else CC = "cc" -$ if p1.eqs."DECC" -$ then CFLAGS = "/noList/Prefix=All" -$ LIBS = "" -$ if f$trnlnm("DECC$CC_DEFAULT").nes."" then CC = CC + "/DECC" -$ else CFLAGS = "/noList/Optimize=noInline" -$ LIBS = "sys$share:vaxcrtl.exe/Shareable" -$ if f$trnlnm("DECC$CC_DEFAULT").nes."" then CC = CC + "/VAXC" -$ if p1.nes."" .and. p1.nes."VAXC" then exit %x002C -$ endif -$ endif -$! -$ no_parser = 0 -$ if p2.eqs."BISON" -$ then YACC = "bison" -$ YACCFLAGS = "/Defines/Fixed_Outfiles" -$ ALLOCA = ",[]alloca.obj" -$ else -$ YACCFLAGS = "-d" -$ ALLOCA = "" -$ if p2.eqs."BYACC" .or. p2.eqs."YACC" -$ then YACC = f$edit(p2,"LOWERCASE") -$ else YACC = "! yacc" -$ if p2.nes."" .and. p2.nes."NO" .and. p2.nes."NONE" then exit %x002C -$ no_parser = 1 -$ endif -$ endif -$! -$ ECHO = "write sys$output" -$ COPY = "copy_" -$ MOVE = "rename_/New_Vers" -$ MUNG = "search_/Exact/Match=NOR" -$ PURGE = "purge_/noConfirm/noLog" -$ REMOVE = "delete_/noConfirm/noLog" -$ TPU = "edit_/TPU/noJournal/noDisplay/noSection" -$! -$ if v then set verify -$! -$ 'COPY' [.misc.vms]vms-conf.h config.h -$ 'COPY' [.misc.vms]vms-code.c vms-code.c -$ 'COPY' [.misc]flex.man flex.doc -$ if ALLOCA.nes."" then 'COPY' [.MISC]alloca.c alloca.c -$ 'COPY' initscan.c scan.c !make.bootstrap -$! -$ if f$search("skel.c").nes."" then - - if f$cvtime(f$file_attr("skel.c","RDT")).gts. - - f$cvtime(f$file_attr("flex.skl","RDT")) then goto skip_mkskel -$ 'TPU' /Command=[.misc.vms]mkskel.tpu flex.skl /Output=skel.c -$skip_mkskel: -$! -$ if f$search("parse.c").nes."" .and. f$search("parse.h").nes."" then - - if f$cvtime(f$file_attr("parse.c","RDT")).gts. - - f$cvtime(f$file_attr("parse.y","RDT")) then goto skip_yacc -$ if f$search("y_tab.%").nes."" then 'REMOVE' y_tab.%;* -$ if no_parser -$ then 'COPY' [.misc]parse.% sys$disk:[]y_tab.* -$ else 'YACC' 'YACCFLAGS' parse.y -$ endif -$ 'MUNG' y_tab.c "#module","#line" /Output=parse.c -$ 'REMOVE' y_tab.c;* -$ 'MOVE' y_tab.h parse.h -$skip_yacc: -$! -$ 'CC' 'CFLAGS' 'CDEFS' /Include=[] ccl.c -$ 'CC' 'CFLAGS' 'CDEFS' /Include=[] dfa.c -$ 'CC' 'CFLAGS' 'CDEFS' /Include=[] ecs.c -$ 'CC' 'CFLAGS' 'CDEFS' /Include=[] gen.c -$ 'CC' 'CFLAGS' 'CDEFS' /Include=[] main.c -$ 'CC' 'CFLAGS' 'CDEFS' /Include=[] misc.c -$ 'CC' 'CFLAGS' 'CDEFS' /Include=[] nfa.c -$ 'CC' 'CFLAGS' 'CDEFS' /Include=[] parse.c -$ 'CC' 'CFLAGS' 'CDEFS' /Include=[] scan.c -$ 'CC' 'CFLAGS' 'CDEFS' /Include=[] skel.c -$ 'CC' 'CFLAGS' 'CDEFS' /Include=[] sym.c -$ 'CC' 'CFLAGS' 'CDEFS' /Include=[] tblcmp.c -$ 'CC' 'CFLAGS' 'CDEFS' /Include=[] yylex.c -$ 'CC' 'CFLAGS' 'CDEFS' /Include=[] vms-code.c -$ if ALLOCA.nes."" then - !bison - 'CC' 'CFLAGS' /Define=("STACK_DIRECTION=-1","xmalloc=yy_flex_xmalloc") alloca.c -$! -$ 'CC' 'CFLAGS' 'CDEFS' /Include=[] libmain.c -$ 'CC' 'CFLAGS' 'CDEFS' /Include=[] libyywrap.c -$ library/Obj flexlib.olb/Create libmain.obj,libyywrap.obj/Insert -$ if f$search("flexlib.olb;-1").nes."" then 'PURGE' flexlib.olb -$! -$ open/Write optfile sys$disk:[]crtl.opt -$ write optfile LIBS -$ close optfile -$ if f$search("crtl.opt;-1").nes."" then 'PURGE' crtl.opt -$! -$ version = "# flex ""2.5""" !default, overridden by version.h -$ open/Read/Error=v_h_2 hfile version.h -$ read/End=v_h_1 hfile version -$v_h_1: close/noLog hfile -$v_h_2: version = f$element(1,"""",version) -$ open/Write optfile sys$disk:[]ident.opt -$ write optfile "identification=""flex ''version'""" -$ close optfile -$ if f$search("ident.opt;-1").nes."" then 'PURGE' ident.opt -$! -$link: -$ link/noMap/Exe=flex.exe ccl.obj,dfa.obj,ecs.obj,gen.obj,main.obj,misc.obj,- - nfa.obj,parse.obj,scan.obj,skel.obj,sym.obj,tblcmp.obj,yylex.obj,- - vms-code.obj 'ALLOCA' ,flexlib.olb/Lib,- - sys$disk:[]crtl.opt/Opt,sys$disk:[]ident.opt/Opt -$! -$ if p3.eqs."NO-CHECK" .or. p3.eqs."NOCHECK" then goto done -$ -$check: -$ 'ECHO' "" -$ 'ECHO' " Checking with COMPRESSION=""""" -$ mcr sys$disk:[]flex.exe -t -p scan.l > scan.chk -$ diff_/Output=_NL:/Maximum_Diff=1 scan.c scan.chk -$ if $status -$ then 'ECHO' " Test passed." -$ 'REMOVE' scan.chk;* -$ else 'ECHO' "? Test failed!" -$ endif -$ -$done: -$ exit diff --git a/commands/flex-2.5.4/MISC/VMS/descrip.mms b/commands/flex-2.5.4/MISC/VMS/descrip.mms deleted file mode 100644 index 5b2859d34..000000000 --- a/commands/flex-2.5.4/MISC/VMS/descrip.mms +++ /dev/null @@ -1,311 +0,0 @@ -# descrip.mms -- makefile for building `flex' using MMS or MMK on VMS; -# created manually from Makefile.in -# flex 2.5.0 Jan'95 - -MAKEFILE = descrip.mms # from [.MISC.VMS] -MAKE = $(MMS) /Descr=$(MAKEFILE) -MAKEFLAGS = $(MMSQUALIFIERS) - -# Possible values for DEFS: -# "VMS" -- used just to make sure parentheses aren't empty; -# For flex to always generate 8-bit scanners, append -# ,"DEFAULT_CSIZE=256" inside /Define=() of DEFS. - -DEFS = /Define=("VMS") -LDFLAGS = /noMap - -# compiler handling -.ifdef GNUC -CC = gcc -GCCINIT = ! SET COMMAND GNU_CC:[000000]GCC -CFLAGS = /noList/Opt=2/Debug/noVerbose -LIBS = gnu_cc:[000000]gcclib.olb/Library, sys$library:vaxcrtl.olb/Library -C_CHOICE = "GNUC=1" -.else ! not GNU C -CC = cc -GCCINIT = -.ifdef DECC -CFLAGS = /noList/Prefix=All -LIBS = -C_CHOICE = "DECC=1" -.else ! not DEC C; assume VAX C -CFLAGS = /noList/Optimize=noInline -LIBS = sys$share:vaxcrtl.exe/Shareable -C_CHOICE = "VAXC=1" -.endif -.endif - -# parser handling -# mms/macro=("xxxC=1","zzz_parser=1"), where "zzz_parser" is -# either "bison_parser" or "byacc_parser" or "yacc_parser", -# otherwise assumed to be "no_parser"; and where "xxxC=1" is -# either "VAXC=1", "GNUC=1", or "DECC=1" as above -.ifdef bison_parser -YACC = bison -YACCFLAGS = /Defines/Fixed_Outfiles -YACCINIT = set command gnu_bison:[000000]bison -ALLOCA = ,[]alloca.obj # note leading comma -.else -YACCFLAGS = -d -YACCINIT = -ALLOCA = -.ifdef byacc_parser -YACC = byacc -.else -.ifdef yacc_parser -YACC = yacc -.else -# none of bison, byacc, or yacc specified -.ifdef no_parser -.else -no_parser=1 -.endif # -.endif #yacc -.endif #byacc -.endif #bison - -# VMS-specific hackery -ECHO = write sys$output # requires single quoted arg -COPY = copy_ # -MOVE = rename_/New_Vers # within same device only -MUNG = search_/Exact/Match=NOR # to strip unwanted `#module' directive -NOOP = continue # non-empty command that does nothing -PURGE = purge_/noConfirm/noLog # relatively quiet file removal -REMOVE = delete_/noConfirm/noLog # ditto -TOUCH = append_/New _NL: # requires single file arg -TPU = edit_/TPU/noJournal/noDisplay/noSection - -# You can define this to be "lex.exe" if you want to replace lex at your site. -FLEX =flex.exe -# note: there should be no whitespace between `=' and the name, -# or else $(FLEX_EXEC) below will not function properly. -FLEXLIB = flexlib.olb - -# You normally do not need to modify anything below this point. -# ------------------------------------------------------------ - -VMSDIR = [.MISC.VMS] -MISCDIR = [.MISC] -CURDIR = sys$disk:[] - -CPPFLAGS = $(DEFS)/Include=[] -LIBOPT = $(CURDIR)crtl.opt # run-time library(s) -ID_OPT = $(CURDIR)ident.opt # version identification - -.SUFFIXES : # avoid overhead of umpteen built-in rules -.SUFFIXES : .obj .c - -.c.obj : - $(CC)$(CFLAGS)$(CPPFLAGS) $< - -VMSHDRS = $(VMSDIR)vms-conf.h # copied to []config.h -VMSSRCS = $(VMSDIR)vms-code.c # copied to []vms-code.c -VMSOBJS = ,vms-code.obj # note leading comma - -HEADERS = flexdef.h version.h - -SOURCES = ccl.c dfa.c ecs.c gen.c main.c misc.c nfa.c parse.y \ - scan.l skel.c sym.c tblcmp.c yylex.c -OBJECTS = ccl.obj,dfa.obj,ecs.obj,gen.obj,main.obj,misc.obj,nfa.obj,parse.obj,\ - scan.obj,skel.obj,sym.obj,tblcmp.obj,yylex.obj $(VMSOBJS) $(ALLOCA) - -LIBSRCS = libmain.c libyywrap.c -LIBOBJS = libmain.obj,libyywrap.obj - -LINTSRCS = ccl.c dfa.c ecs.c gen.c main.c misc.c nfa.c parse.c \ - scan.c skel.c sym.c tblcmp.c yylex.c - -DISTFILES = README NEWS COPYING INSTALL FlexLexer.h \ - configure.in conf.in Makefile.in mkskel.sh flex.skl \ - $(HEADERS) $(SOURCES) $(LIBSRCS) MISC \ - flex.1 scan.c install.sh mkinstalldirs configure - -DIST_NAME = flex - -# flex options to use when generating scan.c from scan.l -COMPRESSION = -PERF_REPORT = -p -# which "flex" to use to generate scan.c from scan.l -FLEX_EXEC = mcr $(CURDIR)$(FLEX) -FLEX_FLAGS = -t $(PERF_REPORT) #$(COMPRESSION) - -MARKER = make.bootstrap - -##### targets start here ##### - -all : $(FLEX) flex.doc - @ $(NOOP) - -install : $(FLEX) flex.doc flex.skl $(FLEXLIB) FlexLexer.h - @ $(ECHO) "-- Installation must be done manually." - @ $(ECHO) " $+" - -.ifdef GCCINIT -.FIRST - $(GCCINIT) - -.endif #GCCINIT - -flex : $(FLEX) - @ $(NOOP) - -$(FLEX) : $(MARKER) $(OBJECTS) $(FLEXLIB) $(LIBOPT) $(ID_OPT) - $(LINK)/Exe=$(FLEX) $(LDFLAGS)\ - $(OBJECTS),$(FLEXLIB)/Lib,$(LIBOPT)/Opt,$(ID_OPT)/Opt - -$(MARKER) : initscan.c - @- if f$search("scan.c").nes."" then $(REMOVE) scan.c;* - $(COPY) initscan.c scan.c - @ $(TOUCH) $(MARKER) - -parse.c : parse.y - @- if f$search("y_tab.%").nes."" then $(REMOVE) y_tab.%;* -.ifdef no_parser - $(COPY) $(MISCDIR)parse.% $(CURDIR)y_tab.* -.else - $(YACCINIT) - $(YACC) $(YACCFLAGS) parse.y -.endif - $(MUNG) y_tab.c "#module","#line" /Output=parse.c - @- $(REMOVE) y_tab.c;* - $(MOVE) y_tab.h parse.h - -parse.h : parse.c - @ $(TOUCH) parse.h - -scan.c : scan.l - $(FLEX_EXEC) $(FLEX_FLAGS) $(COMPRESSION) scan.l > scan.c - -scan.obj : scan.c parse.h flexdef.h config.h -yylex.obj : yylex.c parse.h flexdef.h config.h - -skel.c : flex.skl $(VMSDIR)mkskel.tpu - $(TPU) /Command=$(VMSDIR)mkskel.tpu flex.skl /Output=skel.c - -main.obj : main.c flexdef.h config.h version.h -ccl.obj : ccl.c flexdef.h config.h -dfa.obj : dfa.c flexdef.h config.h -ecs.obj : ecs.c flexdef.h config.h -gen.obj : gen.c flexdef.h config.h -misc.obj : misc.c flexdef.h config.h -nfa.obj : nfa.c flexdef.h config.h -parse.obj : parse.c flexdef.h config.h -skel.obj : skel.c flexdef.h config.h -sym.obj : sym.c flexdef.h config.h -tblcmp.obj : tblcmp.c flexdef.h config.h -vms-code.obj : vms-code.c flexdef.h config.h - -[]alloca.obj : alloca.c - $(CC)$(CFLAGS)/Define=("STACK_DIRECTION=-1","xmalloc=yy_flex_xmalloc") alloca.c - -alloca.c : $(MISCDIR)alloca.c - $(COPY) $(MISCDIR)alloca.c alloca.c - -config.h : $(VMSDIR)vms-conf.h - $(COPY) $(VMSDIR)vms-conf.h config.h - -vms-code.c : $(VMSDIR)vms-code.c - $(COPY) $(VMSDIR)vms-code.c vms-code.c - -test : check - @ $(NOOP) -check : $(FLEX) - @ $(ECHO) "" - @ $(ECHO) " Checking with COMPRESSION="$(COMPRESSION)"" - $(FLEX_EXEC) $(FLEX_FLAGS) $(COMPRESSION) scan.l > scan.chk - diff_/Output=_NL:/Maximum_Diff=1 scan.c scan.chk - -bigcheck : - @- if f$search("scan.c").nes."" then $(REMOVE) scan.c;* - $(MAKE)$(MAKEFLAGS) /Macro=($(C_CHOICE),"COMPRESSION=""-C""") check - @- $(REMOVE) scan.c;* - $(MAKE)$(MAKEFLAGS) /Macro=($(C_CHOICE),"COMPRESSION=""-Ce""") check - @- $(REMOVE) scan.c;* - $(MAKE)$(MAKEFLAGS) /Macro=($(C_CHOICE),"COMPRESSION=""-Cm""") check - @- $(REMOVE) scan.c;* - $(MAKE)$(MAKEFLAGS) /Macro=($(C_CHOICE),"COMPRESSION=""-f""") check - @- $(REMOVE) scan.c;* - $(MAKE)$(MAKEFLAGS) /Macro=($(C_CHOICE),"COMPRESSION=""-Cfea""") check - @- $(REMOVE) scan.c;* - $(MAKE)$(MAKEFLAGS) /Macro=($(C_CHOICE),"COMPRESSION=""-CFer""") check - @- $(REMOVE) scan.c;* - $(MAKE)$(MAKEFLAGS) /Macro=($(C_CHOICE),"COMPRESSION=""-l""","PERF_REPORT=") check - @- $(REMOVE) scan.c;*,scan.chk;* - $(MAKE)$(MAKEFLAGS) $(FLEX) - @- $(PURGE) scan.obj - @ $(ECHO) "All checks successful" - -$(FLEXLIB) : $(LIBOBJS) - library/Obj $(FLEXLIB)/Create $(LIBOBJS)/Insert - @ if f$search("$(FLEXLIB);-1").nes."" then $(PURGE) $(FLEXLIB) - -# We call it .doc instead of .man, to lessen culture shock. :-} -# If MISC/flex.man is out of date relative to flex.1, there's -# not much we can do about it with the tools readily available. -flex.doc : flex.1 - @ if f$search("$(MISCDIR)flex.man").eqs."" then \ - $(COPY) flex.1 $(MISCDIR)flex.man - $(COPY) $(MISCDIR)flex.man flex.doc - -# -# This is completely VMS-specific... -# - -# Linker options file specifying run-time library(s) to link against; -# choice depends on which C compiler is used, and might be empty. -$(LIBOPT) : $(MAKEFILE) - @ open/Write optfile $(LIBOPT) - @ write optfile "$(LIBS)" - @ close optfile - -# Linker options file putting the version number where the ANALYZE/IMAGE -# command will be able to find and report it; assumes that the first line -# of version.h has the version number enclosed within the first and second -# double quotes on it [as in ``#define FLEX_VERSION "2.5.0"'']. -$(ID_OPT) : version.h - @ version = "# flex ""2.5""" !default, overridden by version.h - @- open/Read hfile version.h - @- read hfile version - @- close/noLog hfile - @ version = f$element(1,"""",version) - @ open/Write optfile $(ID_OPT) - @ write optfile "identification=""flex ''version'""" - @ close optfile - - -# -# This is the only stuff moderately useful from the remainder -# of Makefile.in... -# - -mostlyclean : - @- if f$search("scan.chk").nes."" then $(REMOVE) scan.chk;* - @- if f$search("*.obj;-1").nes."" then $(PURGE) *.obj - @- if f$search("*.exe;-1").nes."" then $(PURGE) *.exe - @- if f$search("*.opt;-1").nes."" then $(PURGE) *.opt - -clean : mostlyclean - @- if f$search("*.obj").nes."" then $(REMOVE) *.obj;* - @- if f$search("parse.h").nes."" then $(REMOVE) parse.h;* - @- if f$search("parse.c").nes."" then $(REMOVE) parse.c;* - @- if f$search("alloca.c").nes."" .and.- - f$search("$(MISCDIR)alloca.c").nes."" then $(REMOVE) alloca.c;* - @- if f$search("$(LIBOPT)").nes."" then $(REMOVE) $(LIBOPT);* - @- if f$search("$(ID_OPT)").nes."" then $(REMOVE) $(ID_OPT);* - -distclean : clean - @- if f$search("$(MARKER)").nes."" then $(REMOVE) $(MARKER);* - @- if f$search("$(FLEX)").nes."" then $(REMOVE) $(FLEX);* - @- if f$search("$(FLEXLIB)").nes."" then $(REMOVE) $(FLEXLIB);* - @- if f$search("flex.doc").nes."" then $(REMOVE) flex.doc;* - @- if f$search("scan.c").nes."" then $(REMOVE) scan.c;* - @- if f$search("vms-code.c").nes."" .and.- - f$search("$(VMSDIR)vms-code.c").nes."" then $(REMOVE) vms-code.c;* - @- if f$search("config.h").nes."" .and.- - f$search("$(VMSDIR)vms-conf.h").nes."" then $(REMOVE) config.h;* -# @- if f$search("descrip.mms").nes."" .and.- -# f$search("$(VMSDIR)descrip.mms").nes."" then $(REMOVE) descrip.mms;* - -realclean : distclean - @- if f$search("skel.c").nes."" then $(REMOVE) skel.c;* - diff --git a/commands/flex-2.5.4/MISC/VMS/mkskel.tpu b/commands/flex-2.5.4/MISC/VMS/mkskel.tpu deleted file mode 100644 index e20a0eb30..000000000 --- a/commands/flex-2.5.4/MISC/VMS/mkskel.tpu +++ /dev/null @@ -1,45 +0,0 @@ -! mkskel.tpu -! usage: -! edit/TPU/noDisplay/noSection/Command=mkskel.tpu flex.skl /Output=skel.c -! -! Create a C source file from the flex skeleton data. Copy the file, -! changing backslash (\) to doubled backslash (\\) and quote (") -! to backslash quote (\"). For each line, insert space+space+quote -! at the beginning and quote+comma at the end. Bracket the updated -! text with several lines of prologue and epilogue. -! - skelfile := CREATE_BUFFER("file", GET_INFO(COMMAND_LINE, "file_name")); - SET(NO_WRITE, skelfile); - target := '"' | '\'; !do this once, outside loops - POSITION(BEGINNING_OF(skelfile)); !start here - rest_of_line := CREATE_RANGE(MARK(NONE), MARK(NONE)); !also outside loops - LOOP - EXITIF MARK(NONE) = END_OF(skelfile); !are we done yet? - COPY_TEXT(' "'); start_pos := MARK(NONE); - POSITION(LINE_END); end_pos := MARK(NONE); - MODIFY_RANGE(rest_of_line, start_pos, end_pos); - LOOP - next_match := SEARCH_QUIETLY(target, FORWARD, EXACT, rest_of_line); - EXITIF next_match = 0; - POSITION(BEGINNING_OF(next_match)); - COPY_TEXT('\'); MOVE_HORIZONTAL(1); !past the matched character - MODIFY_RANGE(rest_of_line, MARK(NONE), end_pos); - ENDLOOP; - POSITION(LINE_END); COPY_TEXT('",'); - MOVE_VERTICAL(1); POSITION(LINE_BEGIN); !go to next line - ENDLOOP; - - POSITION(BEGINNING_OF(skelfile)); !insert five line prologue - COPY_TEXT('/* File created from flex.skl via mkskel.tpu */'); SPLIT_LINE; - SPLIT_LINE; - COPY_TEXT('#include "flexdef.h"'); SPLIT_LINE; - SPLIT_LINE; - COPY_TEXT('const char *skel[] = {'); SPLIT_LINE; - - POSITION(END_OF(skelfile)); !append two line epilogue - COPY_TEXT(' 0'); SPLIT_LINE; - COPY_TEXT('};'); !! SPLIT_LINE; - - WRITE_FILE(skelfile, GET_INFO(COMMAND_LINE, "output_file")); - QUIT -!---- diff --git a/commands/flex-2.5.4/MISC/VMS/vms-code.c b/commands/flex-2.5.4/MISC/VMS/vms-code.c deleted file mode 100644 index 825a6b3bb..000000000 --- a/commands/flex-2.5.4/MISC/VMS/vms-code.c +++ /dev/null @@ -1,152 +0,0 @@ -/* vms-code.c -- additional VMS-specific support code for flex - */ - -#include "flexdef.h" - -static const char *original_arg0; -static const char default_arg0[] = "flex.exe"; - -#define IN_FD 0 -#define OUT_FD 1 -#define ERR_FD 2 - -static char *fix_arg0 PROTO((const char *)); - -/* Command line arguments fixup -- simplify argv[0], and handle `>' - output redirection request; called first thing from main(). */ - -void argv_fixup( iargc, iargv ) -int *iargc; -char ***iargv; -{ - const char *mode[3], *rfm[3], *name[3]; - char *p; - int i, oargc, punct, which, append, alt_rfm; - - /* - * Get original argv[0] supplied by run-time library startup code, - * then replace it with a stripped down one. - */ - original_arg0 = (*iargv)[0]; - (*iargv)[0] = fix_arg0(original_arg0); - - /* - * Check command line arguments for redirection request(s). - * For simplicity, if multiple attempts are made, the last one wins. - */ - name[0] = name[1] = name[2] = 0; - oargc = 1; /* number of args caller will see; count includes argv[0] */ - for (i = 1; i < *iargc; i++) { - p = (*iargv)[i]; - switch (*p) { - case '<': - /* might be "file"; then again, perhaps "<file" */ - punct = (strchr(p, '>') != 0); - if (p[1] == '<') { - if (!punct || p[2] == '<') - flexerror("<<'sentinel' input not supported."); - punct = 0; - } - if (punct) /* the '<' seems to be directory punctuation */ - goto arg; /*GOTO*/ - mode[IN_FD] = "r"; - rfm[IN_FD] = 0; - name[IN_FD] = ++p; - if (!*p && (i + 1) < *iargc) - name[IN_FD] = (*iargv)[++i]; - break; - case '>': - append = (p[1] == '>'); - if (append) ++p; - alt_rfm = (p[1] == '$'); - if (alt_rfm) ++p; - which = (p[1] == '&' ? ERR_FD : OUT_FD); - if (which == ERR_FD) ++p; - mode[which] = append ? "a" : "w"; - rfm[which] = alt_rfm ? "rfm=var" : "rfm=stmlf"; - name[which] = ++p; - if (!*p && (i + 1) < *iargc) - name[which] = (*iargv)[++i]; - break; - case '|': - flexerror("pipe output not supported."); - /*NOTREACHED*/ - break; - default: - arg: /* ordinary option or argument */ - (*iargv)[oargc++] = p; - break; - } - } - /* perform any requested redirection; don't bother with SYS$xxx logicals */ - if (name[IN_FD]) - if (!freopen(name[IN_FD], mode[IN_FD], stdin)) - lerrsf("failed to redirect `stdin' from \"%s\"", name[IN_FD]); - if (name[OUT_FD]) - if (!freopen(name[OUT_FD], mode[OUT_FD], stdout, - rfm[OUT_FD], "rat=cr", "mbc=32", "shr=nil")) - lerrsf("failed to redirect `stdout' to \"%s\"", name[OUT_FD]); - if (name[ERR_FD]) /* likely won't see message if this fails; oh well... */ - if (!freopen(name[ERR_FD], mode[ERR_FD], stderr, - rfm[ERR_FD], "rat=cr")) - lerrsf("failed to redirect `stderr' to \"%s\"", name[ERR_FD]); - /* remove any excess arguments (used up from redirection) */ - while (*iargc > oargc) - (*iargv)[--*iargc] = 0; - /* all done */ - return; -} - -/* Pick out the basename of a full filename, and return a pointer - to a modifiable copy of it. */ - -static char *fix_arg0( arg0 ) -const char *arg0; -{ - char *p, *new_arg0; - - if (arg0) { - /* strip off the path */ - if ((p = strrchr(arg0, ':')) != 0) /* device punctuation */ - arg0 = p + 1; - if ((p = strrchr(arg0, ']')) != 0) /* directory punctuation */ - arg0 = p + 1; - if ((p = strrchr(arg0, '>')) != 0) /* alternate dir punct */ - arg0 = p + 1; - } - if (!arg0 || !*arg0) - arg0 = default_arg0; - /* should now have "something.exe;#"; make a modifiable copy */ - new_arg0 = copy_string(arg0); - - /* strip off ".exe" and/or ";#" (version number), - unless it ended up as the whole name */ - if ((p = strchr(new_arg0, '.')) != 0 && (p > new_arg0) - && (p[1] == 'e' || p[1] == 'E') - && (p[2] == 'x' || p[2] == 'X') - && (p[3] == 'e' || p[3] == 'E') - && (p[4] == ';' || p[4] == '.' || p[4] == '\0')) - *p = '\0'; - else if ((p = strchr(new_arg0, ';')) != 0 && (p > new_arg0)) - *p = '\0'; - - return new_arg0; -} - - -#include -#include - -#ifdef exit -#undef exit -extern void exit PROTO((int)); /* ended up prototyping vms_exit */ -#endif - -/* Convert zero to VMS success and non-zero to VMS failure. The latter - does not bother trying to distinguish between various failure reasons. */ - -void vms_exit( status ) -int status; -{ - exit( status == 0 ? SS$_NORMAL : (SS$_ABORT | STS$M_INHIB_MSG) ); -} diff --git a/commands/flex-2.5.4/MISC/VMS/vms-conf.h b/commands/flex-2.5.4/MISC/VMS/vms-conf.h deleted file mode 100644 index 65aa477ec..000000000 --- a/commands/flex-2.5.4/MISC/VMS/vms-conf.h +++ /dev/null @@ -1,32 +0,0 @@ -/* config.h manually constructed for VMS */ - -/* Define to empty if the keyword does not work. */ -#undef const - -/* Define to `unsigned' if doesn't define. */ -#undef size_t - -/* Define if you have the ANSI C header files. */ -#define STDC_HEADERS - -/* Define if you have the header file. */ -#undef HAVE_MALLOC_H - -/* Define if you have the header file. */ -#define HAVE_STRING_H - -/* Define if you have the header file. */ -#ifndef __GNUC__ -#undef HAVE_SYS_TYPES_H -#else -#define HAVE_SYS_TYPES_H -#endif - -/* Define if you have and it should be used (not on Ultrix). */ -#undef HAVE_ALLOCA_H - -/* Extra platform-specific command line handling. */ -#define NEED_ARGV_FIXUP - -/* Override default exit behavior. */ -#define exit vms_exit diff --git a/commands/flex-2.5.4/MISC/alloca.c b/commands/flex-2.5.4/MISC/alloca.c deleted file mode 100644 index bd4932aa4..000000000 --- a/commands/flex-2.5.4/MISC/alloca.c +++ /dev/null @@ -1,484 +0,0 @@ -/* alloca.c -- allocate automatically reclaimed memory - (Mostly) portable public-domain implementation -- D A Gwyn - - This implementation of the PWB library alloca function, - which is used to allocate space off the run-time stack so - that it is automatically reclaimed upon procedure exit, - was inspired by discussions with J. Q. Johnson of Cornell. - J.Otto Tennant contributed the Cray support. - - There are some preprocessor constants that can - be defined when compiling for your specific system, for - improved efficiency; however, the defaults should be okay. - - The general concept of this implementation is to keep - track of all alloca-allocated blocks, and reclaim any - that are found to be deeper in the stack than the current - invocation. This heuristic does not reclaim storage as - soon as it becomes invalid, but it will do so eventually. - - As a special case, alloca(0) reclaims storage without - allocating any. It is a good idea to use alloca(0) in - your main control loop, etc. to force garbage collection. */ - -#ifdef HAVE_CONFIG_H -#if defined (emacs) || defined (CONFIG_BROKETS) -#include -#else -#include "config.h" -#endif -#endif - -/* If compiling with GCC 2, this file's not needed. */ -#if !defined (__GNUC__) || __GNUC__ < 2 - -/* If someone has defined alloca as a macro, - there must be some other way alloca is supposed to work. */ -#ifndef alloca - -#ifdef emacs -#ifdef static -/* actually, only want this if static is defined as "" - -- this is for usg, in which emacs must undefine static - in order to make unexec workable - */ -#ifndef STACK_DIRECTION -you -lose --- must know STACK_DIRECTION at compile-time -#endif /* STACK_DIRECTION undefined */ -#endif /* static */ -#endif /* emacs */ - -/* If your stack is a linked list of frames, you have to - provide an "address metric" ADDRESS_FUNCTION macro. */ - -#if defined (CRAY) && defined (CRAY_STACKSEG_END) -long i00afunc (); -#define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg)) -#else -#define ADDRESS_FUNCTION(arg) &(arg) -#endif - -#if __STDC__ -typedef void *pointer; -#else -typedef char *pointer; -#endif - -#define NULL 0 - -/* Different portions of Emacs need to call different versions of - malloc. The Emacs executable needs alloca to call xmalloc, because - ordinary malloc isn't protected from input signals. On the other - hand, the utilities in lib-src need alloca to call malloc; some of - them are very simple, and don't have an xmalloc routine. - - Non-Emacs programs expect this to call use xmalloc. - - Callers below should use malloc. */ - -#ifndef emacs -#define malloc xmalloc -#endif -extern pointer malloc (); - -/* Define STACK_DIRECTION if you know the direction of stack - growth for your system; otherwise it will be automatically - deduced at run-time. - - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown */ - -#ifndef STACK_DIRECTION -#define STACK_DIRECTION 0 /* Direction unknown. */ -#endif - -#if STACK_DIRECTION != 0 - -#define STACK_DIR STACK_DIRECTION /* Known at compile-time. */ - -#else /* STACK_DIRECTION == 0; need run-time code. */ - -static int stack_dir; /* 1 or -1 once known. */ -#define STACK_DIR stack_dir - -static void -find_stack_direction () -{ - static char *addr = NULL; /* Address of first `dummy', once known. */ - auto char dummy; /* To get stack address. */ - - if (addr == NULL) - { /* Initial entry. */ - addr = ADDRESS_FUNCTION (dummy); - - find_stack_direction (); /* Recurse once. */ - } - else - { - /* Second entry. */ - if (ADDRESS_FUNCTION (dummy) > addr) - stack_dir = 1; /* Stack grew upward. */ - else - stack_dir = -1; /* Stack grew downward. */ - } -} - -#endif /* STACK_DIRECTION == 0 */ - -/* An "alloca header" is used to: - (a) chain together all alloca'ed blocks; - (b) keep track of stack depth. - - It is very important that sizeof(header) agree with malloc - alignment chunk size. The following default should work okay. */ - -#ifndef ALIGN_SIZE -#define ALIGN_SIZE sizeof(double) -#endif - -typedef union hdr -{ - char align[ALIGN_SIZE]; /* To force sizeof(header). */ - struct - { - union hdr *next; /* For chaining headers. */ - char *deep; /* For stack depth measure. */ - } h; -} header; - -static header *last_alloca_header = NULL; /* -> last alloca header. */ - -/* Return a pointer to at least SIZE bytes of storage, - which will be automatically reclaimed upon exit from - the procedure that called alloca. Originally, this space - was supposed to be taken from the current stack frame of the - caller, but that method cannot be made to work for some - implementations of C, for example under Gould's UTX/32. */ - -pointer -alloca (size) - unsigned size; -{ - auto char probe; /* Probes stack depth: */ - register char *depth = ADDRESS_FUNCTION (probe); - -#if STACK_DIRECTION == 0 - if (STACK_DIR == 0) /* Unknown growth direction. */ - find_stack_direction (); -#endif - - /* Reclaim garbage, defined as all alloca'd storage that - was allocated from deeper in the stack than currently. */ - - { - register header *hp; /* Traverses linked list. */ - - for (hp = last_alloca_header; hp != NULL;) - if ((STACK_DIR > 0 && hp->h.deep > depth) - || (STACK_DIR < 0 && hp->h.deep < depth)) - { - register header *np = hp->h.next; - - free ((pointer) hp); /* Collect garbage. */ - - hp = np; /* -> next header. */ - } - else - break; /* Rest are not deeper. */ - - last_alloca_header = hp; /* -> last valid storage. */ - } - - if (size == 0) - return NULL; /* No allocation required. */ - - /* Allocate combined header + user data storage. */ - - { - register pointer new = malloc (sizeof (header) + size); - /* Address of header. */ - - ((header *) new)->h.next = last_alloca_header; - ((header *) new)->h.deep = depth; - - last_alloca_header = (header *) new; - - /* User storage begins just after header. */ - - return (pointer) ((char *) new + sizeof (header)); - } -} - -#if defined (CRAY) && defined (CRAY_STACKSEG_END) - -#ifdef DEBUG_I00AFUNC -#include -#endif - -#ifndef CRAY_STACK -#define CRAY_STACK -#ifndef CRAY2 -/* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */ -struct stack_control_header - { - long shgrow:32; /* Number of times stack has grown. */ - long shaseg:32; /* Size of increments to stack. */ - long shhwm:32; /* High water mark of stack. */ - long shsize:32; /* Current size of stack (all segments). */ - }; - -/* The stack segment linkage control information occurs at - the high-address end of a stack segment. (The stack - grows from low addresses to high addresses.) The initial - part of the stack segment linkage control information is - 0200 (octal) words. This provides for register storage - for the routine which overflows the stack. */ - -struct stack_segment_linkage - { - long ss[0200]; /* 0200 overflow words. */ - long sssize:32; /* Number of words in this segment. */ - long ssbase:32; /* Offset to stack base. */ - long:32; - long sspseg:32; /* Offset to linkage control of previous - segment of stack. */ - long:32; - long sstcpt:32; /* Pointer to task common address block. */ - long sscsnm; /* Private control structure number for - microtasking. */ - long ssusr1; /* Reserved for user. */ - long ssusr2; /* Reserved for user. */ - long sstpid; /* Process ID for pid based multi-tasking. */ - long ssgvup; /* Pointer to multitasking thread giveup. */ - long sscray[7]; /* Reserved for Cray Research. */ - long ssa0; - long ssa1; - long ssa2; - long ssa3; - long ssa4; - long ssa5; - long ssa6; - long ssa7; - long sss0; - long sss1; - long sss2; - long sss3; - long sss4; - long sss5; - long sss6; - long sss7; - }; - -#else /* CRAY2 */ -/* The following structure defines the vector of words - returned by the STKSTAT library routine. */ -struct stk_stat - { - long now; /* Current total stack size. */ - long maxc; /* Amount of contiguous space which would - be required to satisfy the maximum - stack demand to date. */ - long high_water; /* Stack high-water mark. */ - long overflows; /* Number of stack overflow ($STKOFEN) calls. */ - long hits; /* Number of internal buffer hits. */ - long extends; /* Number of block extensions. */ - long stko_mallocs; /* Block allocations by $STKOFEN. */ - long underflows; /* Number of stack underflow calls ($STKRETN). */ - long stko_free; /* Number of deallocations by $STKRETN. */ - long stkm_free; /* Number of deallocations by $STKMRET. */ - long segments; /* Current number of stack segments. */ - long maxs; /* Maximum number of stack segments so far. */ - long pad_size; /* Stack pad size. */ - long current_address; /* Current stack segment address. */ - long current_size; /* Current stack segment size. This - number is actually corrupted by STKSTAT to - include the fifteen word trailer area. */ - long initial_address; /* Address of initial segment. */ - long initial_size; /* Size of initial segment. */ - }; - -/* The following structure describes the data structure which trails - any stack segment. I think that the description in 'asdef' is - out of date. I only describe the parts that I am sure about. */ - -struct stk_trailer - { - long this_address; /* Address of this block. */ - long this_size; /* Size of this block (does not include - this trailer). */ - long unknown2; - long unknown3; - long link; /* Address of trailer block of previous - segment. */ - long unknown5; - long unknown6; - long unknown7; - long unknown8; - long unknown9; - long unknown10; - long unknown11; - long unknown12; - long unknown13; - long unknown14; - }; - -#endif /* CRAY2 */ -#endif /* not CRAY_STACK */ - -#ifdef CRAY2 -/* Determine a "stack measure" for an arbitrary ADDRESS. - I doubt that "lint" will like this much. */ - -static long -i00afunc (long *address) -{ - struct stk_stat status; - struct stk_trailer *trailer; - long *block, size; - long result = 0; - - /* We want to iterate through all of the segments. The first - step is to get the stack status structure. We could do this - more quickly and more directly, perhaps, by referencing the - $LM00 common block, but I know that this works. */ - - STKSTAT (&status); - - /* Set up the iteration. */ - - trailer = (struct stk_trailer *) (status.current_address - + status.current_size - - 15); - - /* There must be at least one stack segment. Therefore it is - a fatal error if "trailer" is null. */ - - if (trailer == 0) - abort (); - - /* Discard segments that do not contain our argument address. */ - - while (trailer != 0) - { - block = (long *) trailer->this_address; - size = trailer->this_size; - if (block == 0 || size == 0) - abort (); - trailer = (struct stk_trailer *) trailer->link; - if ((block <= address) && (address < (block + size))) - break; - } - - /* Set the result to the offset in this segment and add the sizes - of all predecessor segments. */ - - result = address - block; - - if (trailer == 0) - { - return result; - } - - do - { - if (trailer->this_size <= 0) - abort (); - result += trailer->this_size; - trailer = (struct stk_trailer *) trailer->link; - } - while (trailer != 0); - - /* We are done. Note that if you present a bogus address (one - not in any segment), you will get a different number back, formed - from subtracting the address of the first block. This is probably - not what you want. */ - - return (result); -} - -#else /* not CRAY2 */ -/* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP. - Determine the number of the cell within the stack, - given the address of the cell. The purpose of this - routine is to linearize, in some sense, stack addresses - for alloca. */ - -static long -i00afunc (long address) -{ - long stkl = 0; - - long size, pseg, this_segment, stack; - long result = 0; - - struct stack_segment_linkage *ssptr; - - /* Register B67 contains the address of the end of the - current stack segment. If you (as a subprogram) store - your registers on the stack and find that you are past - the contents of B67, you have overflowed the segment. - - B67 also points to the stack segment linkage control - area, which is what we are really interested in. */ - - stkl = CRAY_STACKSEG_END (); - ssptr = (struct stack_segment_linkage *) stkl; - - /* If one subtracts 'size' from the end of the segment, - one has the address of the first word of the segment. - - If this is not the first segment, 'pseg' will be - nonzero. */ - - pseg = ssptr->sspseg; - size = ssptr->sssize; - - this_segment = stkl - size; - - /* It is possible that calling this routine itself caused - a stack overflow. Discard stack segments which do not - contain the target address. */ - - while (!(this_segment <= address && address <= stkl)) - { -#ifdef DEBUG_I00AFUNC - fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl); -#endif - if (pseg == 0) - break; - stkl = stkl - pseg; - ssptr = (struct stack_segment_linkage *) stkl; - size = ssptr->sssize; - pseg = ssptr->sspseg; - this_segment = stkl - size; - } - - result = address - this_segment; - - /* If you subtract pseg from the current end of the stack, - you get the address of the previous stack segment's end. - This seems a little convoluted to me, but I'll bet you save - a cycle somewhere. */ - - while (pseg != 0) - { -#ifdef DEBUG_I00AFUNC - fprintf (stderr, "%011o %011o\n", pseg, size); -#endif - stkl = stkl - pseg; - ssptr = (struct stack_segment_linkage *) stkl; - size = ssptr->sssize; - pseg = ssptr->sspseg; - result += size; - } - return (result); -} - -#endif /* not CRAY2 */ -#endif /* CRAY */ - -#endif /* no alloca */ -#endif /* not GCC version 2 */ diff --git a/commands/flex-2.5.4/MISC/debflex.awk b/commands/flex-2.5.4/MISC/debflex.awk deleted file mode 100644 index b1eda49c4..000000000 --- a/commands/flex-2.5.4/MISC/debflex.awk +++ /dev/null @@ -1,119 +0,0 @@ -# Clarify the flex debug trace by substituting first line of each rule. -# Francois Pinard , July 1990. -# -# Rewritten to process correctly \n's in scanner input. -# BEGIN section modified to correct a collection of rules. -# Michal Jaegermann , December 1993 -# -# Sample usage: -# flex -d PROGRAM.l -# gcc -o PROGRAM PROGRAM.c -lfl -# PROGRAM 2>&1 | gawk -f debflex.awk PROGRAM.l -# -# (VP's note: this script presently does not work with either "old" or -# "new" awk; fixes so it does will be welcome) - -BEGIN { - # Insure proper usage. - - if (ARGC != 2) { - print "usage: gawk -f debflex.awk FLEX_SOURCE -#include - -main() -{ - register int c, cc = 0, wc = 0, lc = 0; - FILE *f = stdin; - - while ((c = getc(f)) != EOF) { - ++cc; - if (isgraph(c)) { - ++wc; - do { - c = getc(f); - if (c == EOF) - goto done; - ++cc; - } while (isgraph(c)); - } - if (c == '\n') - ++lc; - } -done: printf( "%8d%8d%8d\n", lc, wc, cc ); -} diff --git a/commands/flex-2.5.4/MISC/fastwc/wc1.l b/commands/flex-2.5.4/MISC/fastwc/wc1.l deleted file mode 100644 index d6696bcde..000000000 --- a/commands/flex-2.5.4/MISC/fastwc/wc1.l +++ /dev/null @@ -1,18 +0,0 @@ -/* First cut at a flex-based "wc" tool. */ - -ws [ \t] -nonws [^ \t\n] - -%% - int cc = 0, wc = 0, lc = 0; - -{nonws}+ cc += yyleng; ++wc; - -{ws}+ cc += yyleng; - -\n ++lc; ++cc; - -<> { - printf( "%8d %8d %8d\n", lc, wc, cc ); - yyterminate(); - } diff --git a/commands/flex-2.5.4/MISC/fastwc/wc2.l b/commands/flex-2.5.4/MISC/fastwc/wc2.l deleted file mode 100644 index bd63cd490..000000000 --- a/commands/flex-2.5.4/MISC/fastwc/wc2.l +++ /dev/null @@ -1,20 +0,0 @@ -/* Somewhat faster "wc" tool: match more text with each rule */ - -ws [ \t] -nonws [^ \t\n] -word {ws}*{nonws}+ - -%% - int cc = 0, wc = 0, lc = 0; - -{word}{ws}* cc += yyleng; ++wc; -{word}{ws}*\n cc += yyleng; ++wc; ++lc; - -{ws}+ cc += yyleng; - -\n+ cc += yyleng; lc += yyleng; - -<> { - printf( "%8d %8d %8d\n", lc, wc, cc ); - yyterminate(); - } diff --git a/commands/flex-2.5.4/MISC/fastwc/wc3.l b/commands/flex-2.5.4/MISC/fastwc/wc3.l deleted file mode 100644 index 7c5f2e271..000000000 --- a/commands/flex-2.5.4/MISC/fastwc/wc3.l +++ /dev/null @@ -1,24 +0,0 @@ -/* Somewhat faster still: potentially match a lot of text with each rule */ - -ws [ \t] -nonws [^ \t\n] -word {ws}*{nonws}+ -words {word}{ws}+ - -%% - int cc = 0, wc = 0, lc = 0; - -{word}{ws}* cc += yyleng; ++wc; -{word}{ws}*\n cc += yyleng; ++wc; ++lc; -{words}{word}{ws}* cc += yyleng; wc += 2; -{words}{2}{word}{ws}* cc += yyleng; wc += 3; -{words}{3}{word}{ws}* cc += yyleng; wc += 4; - -{ws}+ cc += yyleng; - -\n+ cc += yyleng; lc += yyleng; - -<> { - printf( "%8d %8d %8d\n", lc, wc, cc ); - yyterminate(); - } diff --git a/commands/flex-2.5.4/MISC/fastwc/wc4.l b/commands/flex-2.5.4/MISC/fastwc/wc4.l deleted file mode 100644 index cbe56f6e1..000000000 --- a/commands/flex-2.5.4/MISC/fastwc/wc4.l +++ /dev/null @@ -1,27 +0,0 @@ -/* Fastest version of wc: add rules to pick up newlines, too */ - -ws [ \t] -nonws [^ \t\n] -word {ws}*{nonws}+ -words {word}{ws}+ - -%% - int cc = 0, wc = 0, lc = 0; - -{word}{ws}* ++wc; cc += yyleng; -{word}{ws}*\n ++wc; cc += yyleng; ++lc; -{words}{word}{ws}* wc += 2; cc += yyleng; -{words}{word}{ws}*\n wc += 2; cc += yyleng; ++lc; -{words}{2}{word}{ws}* wc += 3; cc += yyleng; -{words}{2}{word}{ws}*\n wc += 3; cc += yyleng; ++lc; -{words}{3}{word}{ws}* wc += 4; cc += yyleng; -{words}{3}{word}{ws}*\n wc += 4; cc += yyleng; ++lc; - -{ws}+ cc += yyleng; - -\n+ cc += yyleng; lc += yyleng; - -<> { - printf( "%8d %8d %8d\n", lc, wc, cc ); - yyterminate(); - } diff --git a/commands/flex-2.5.4/MISC/fastwc/wc5.l b/commands/flex-2.5.4/MISC/fastwc/wc5.l deleted file mode 100644 index 8fe17b622..000000000 --- a/commands/flex-2.5.4/MISC/fastwc/wc5.l +++ /dev/null @@ -1,24 +0,0 @@ -/* Oops; slight change from wc3.l introduces backtracking */ - -ws [ \t] -nonws [^ \t\n] -word {ws}*{nonws}+ -words {word}{ws}+ - -%% - int cc = 0, wc = 0, lc = 0; - -{word}{ws}* cc += yyleng; ++wc; -{word}{ws}*\n cc += yyleng; ++wc; ++lc; -{words}{word} cc += yyleng; wc += 2; /* oops */ -{words}{2}{word}{ws}* cc += yyleng; wc += 3; -{words}{3}{word}{ws}* cc += yyleng; wc += 4; - -{ws}+ cc += yyleng; - -\n+ cc += yyleng; lc += yyleng; - -<> { - printf( "%8d %8d %8d\n", lc, wc, cc ); - yyterminate(); - } diff --git a/commands/flex-2.5.4/MISC/flex.man b/commands/flex-2.5.4/MISC/flex.man deleted file mode 100644 index d41f5ba5b..000000000 --- a/commands/flex-2.5.4/MISC/flex.man +++ /dev/null @@ -1,3696 +0,0 @@ - - - -FLEX(1) USER COMMANDS FLEX(1) - - - -NAME - flex - fast lexical analyzer generator - -SYNOPSIS - flex [-bcdfhilnpstvwBFILTV78+? -C[aefFmr] -ooutput -Pprefix - -Sskeleton] [--help --version] [filename ...] - -OVERVIEW - This manual describes flex, a tool for generating programs - that perform pattern-matching on text. The manual includes - both tutorial and reference sections: - - Description - a brief overview of the tool - - Some Simple Examples - - Format Of The Input File - - Patterns - the extended regular expressions used by flex - - How The Input Is Matched - the rules for determining what has been matched - - Actions - how to specify what to do when a pattern is matched - - The Generated Scanner - details regarding the scanner that flex produces; - how to control the input source - - Start Conditions - introducing context into your scanners, and - managing "mini-scanners" - - Multiple Input Buffers - how to manipulate multiple input sources; how to - scan from strings instead of files - - End-of-file Rules - special rules for matching the end of the input - - Miscellaneous Macros - a summary of macros available to the actions - - Values Available To The User - a summary of values available to the actions - - Interfacing With Yacc - connecting flex scanners together with yacc parsers - - - - -Version 2.5 Last change: April 1995 1 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - Options - flex command-line options, and the "%option" - directive - - Performance Considerations - how to make your scanner go as fast as possible - - Generating C++ Scanners - the (experimental) facility for generating C++ - scanner classes - - Incompatibilities With Lex And POSIX - how flex differs from AT&T lex and the POSIX lex - standard - - Diagnostics - those error messages produced by flex (or scanners - it generates) whose meanings might not be apparent - - Files - files used by flex - - Deficiencies / Bugs - known problems with flex - - See Also - other documentation, related tools - - Author - includes contact information - - -DESCRIPTION - flex is a tool for generating scanners: programs which - recognized lexical patterns in text. flex reads the given - input files, or its standard input if no file names are - given, for a description of a scanner to generate. The - description is in the form of pairs of regular expressions - and C code, called rules. flex generates as output a C - source file, lex.yy.c, which defines a routine yylex(). This - file is compiled and linked with the -lfl library to produce - an executable. When the executable is run, it analyzes its - input for occurrences of the regular expressions. Whenever - it finds one, it executes the corresponding C code. - -SOME SIMPLE EXAMPLES - First some simple examples to get the flavor of how one uses - flex. The following flex input specifies a scanner which - whenever it encounters the string "username" will replace it - with the user's login name: - - %% - - - -Version 2.5 Last change: April 1995 2 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - username printf( "%s", getlogin() ); - - By default, any text not matched by a flex scanner is copied - to the output, so the net effect of this scanner is to copy - its input file to its output with each occurrence of "user- - name" expanded. In this input, there is just one rule. - "username" is the pattern and the "printf" is the action. - The "%%" marks the beginning of the rules. - - Here's another simple example: - - int num_lines = 0, num_chars = 0; - - %% - \n ++num_lines; ++num_chars; - . ++num_chars; - - %% - main() - { - yylex(); - printf( "# of lines = %d, # of chars = %d\n", - num_lines, num_chars ); - } - - This scanner counts the number of characters and the number - of lines in its input (it produces no output other than the - final report on the counts). The first line declares two - globals, "num_lines" and "num_chars", which are accessible - both inside yylex() and in the main() routine declared after - the second "%%". There are two rules, one which matches a - newline ("\n") and increments both the line count and the - character count, and one which matches any character other - than a newline (indicated by the "." regular expression). - - A somewhat more complicated example: - - /* scanner for a toy Pascal-like language */ - - %{ - /* need this for the call to atof() below */ - #include - %} - - DIGIT [0-9] - ID [a-z][a-z0-9]* - - %% - - {DIGIT}+ { - printf( "An integer: %s (%d)\n", yytext, - atoi( yytext ) ); - - - -Version 2.5 Last change: April 1995 3 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - } - - {DIGIT}+"."{DIGIT}* { - printf( "A float: %s (%g)\n", yytext, - atof( yytext ) ); - } - - if|then|begin|end|procedure|function { - printf( "A keyword: %s\n", yytext ); - } - - {ID} printf( "An identifier: %s\n", yytext ); - - "+"|"-"|"*"|"/" printf( "An operator: %s\n", yytext ); - - "{"[^}\n]*"}" /* eat up one-line comments */ - - [ \t\n]+ /* eat up whitespace */ - - . printf( "Unrecognized character: %s\n", yytext ); - - %% - - main( argc, argv ) - int argc; - char **argv; - { - ++argv, --argc; /* skip over program name */ - if ( argc > 0 ) - yyin = fopen( argv[0], "r" ); - else - yyin = stdin; - - yylex(); - } - - This is the beginnings of a simple scanner for a language - like Pascal. It identifies different types of tokens and - reports on what it has seen. - - The details of this example will be explained in the follow- - ing sections. - -FORMAT OF THE INPUT FILE - The flex input file consists of three sections, separated by - a line with just %% in it: - - definitions - %% - rules - %% - user code - - - -Version 2.5 Last change: April 1995 4 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - The definitions section contains declarations of simple name - definitions to simplify the scanner specification, and - declarations of start conditions, which are explained in a - later section. - - Name definitions have the form: - - name definition - - The "name" is a word beginning with a letter or an under- - score ('_') followed by zero or more letters, digits, '_', - or '-' (dash). The definition is taken to begin at the - first non-white-space character following the name and con- - tinuing to the end of the line. The definition can subse- - quently be referred to using "{name}", which will expand to - "(definition)". For example, - - DIGIT [0-9] - ID [a-z][a-z0-9]* - - defines "DIGIT" to be a regular expression which matches a - single digit, and "ID" to be a regular expression which - matches a letter followed by zero-or-more letters-or-digits. - A subsequent reference to - - {DIGIT}+"."{DIGIT}* - - is identical to - - ([0-9])+"."([0-9])* - - and matches one-or-more digits followed by a '.' followed by - zero-or-more digits. - - The rules section of the flex input contains a series of - rules of the form: - - pattern action - - where the pattern must be unindented and the action must - begin on the same line. - - See below for a further description of patterns and actions. - - Finally, the user code section is simply copied to lex.yy.c - verbatim. It is used for companion routines which call or - are called by the scanner. The presence of this section is - optional; if it is missing, the second %% in the input file - may be skipped, too. - - In the definitions and rules sections, any indented text or - text enclosed in %{ and %} is copied verbatim to the output - - - -Version 2.5 Last change: April 1995 5 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - (with the %{}'s removed). The %{}'s must appear unindented - on lines by themselves. - - In the rules section, any indented or %{} text appearing - before the first rule may be used to declare variables which - are local to the scanning routine and (after the declara- - tions) code which is to be executed whenever the scanning - routine is entered. Other indented or %{} text in the rule - section is still copied to the output, but its meaning is - not well-defined and it may well cause compile-time errors - (this feature is present for POSIX compliance; see below for - other such features). - - In the definitions section (but not in the rules section), - an unindented comment (i.e., a line beginning with "/*") is - also copied verbatim to the output up to the next "*/". - -PATTERNS - The patterns in the input are written using an extended set - of regular expressions. These are: - - x match the character 'x' - . any character (byte) except newline - [xyz] a "character class"; in this case, the pattern - matches either an 'x', a 'y', or a 'z' - [abj-oZ] a "character class" with a range in it; matches - an 'a', a 'b', any letter from 'j' through 'o', - or a 'Z' - [^A-Z] a "negated character class", i.e., any character - but those in the class. In this case, any - character EXCEPT an uppercase letter. - [^A-Z\n] any character EXCEPT an uppercase letter or - a newline - r* zero or more r's, where r is any regular expression - r+ one or more r's - r? zero or one r's (that is, "an optional r") - r{2,5} anywhere from two to five r's - r{2,} two or more r's - r{4} exactly 4 r's - {name} the expansion of the "name" definition - (see above) - "[xyz]\"foo" - the literal string: [xyz]"foo - \X if X is an 'a', 'b', 'f', 'n', 'r', 't', or 'v', - then the ANSI-C interpretation of \x. - Otherwise, a literal 'X' (used to escape - operators such as '*') - \0 a NUL character (ASCII code 0) - \123 the character with octal value 123 - \x2a the character with hexadecimal value 2a - (r) match an r; parentheses are used to override - precedence (see below) - - - -Version 2.5 Last change: April 1995 6 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - rs the regular expression r followed by the - regular expression s; called "concatenation" - - - r|s either an r or an s - - - r/s an r but only if it is followed by an s. The - text matched by s is included when determining - whether this rule is the "longest match", - but is then returned to the input before - the action is executed. So the action only - sees the text matched by r. This type - of pattern is called trailing context". - (There are some combinations of r/s that flex - cannot match correctly; see notes in the - Deficiencies / Bugs section below regarding - "dangerous trailing context".) - ^r an r, but only at the beginning of a line (i.e., - which just starting to scan, or right after a - newline has been scanned). - r$ an r, but only at the end of a line (i.e., just - before a newline). Equivalent to "r/\n". - - Note that flex's notion of "newline" is exactly - whatever the C compiler used to compile flex - interprets '\n' as; in particular, on some DOS - systems you must either filter out \r's in the - input yourself, or explicitly use r/\r\n for "r$". - - - r an r, but only in start condition s (see - below for discussion of start conditions) - r - same, but in any of start conditions s1, - s2, or s3 - <*>r an r in any start condition, even an exclusive one. - - - <> an end-of-file - <> - an end-of-file when in start condition s1 or s2 - - Note that inside of a character class, all regular expres- - sion operators lose their special meaning except escape - ('\') and the character class operators, '-', ']', and, at - the beginning of the class, '^'. - - The regular expressions listed above are grouped according - to precedence, from highest precedence at the top to lowest - at the bottom. Those grouped together have equal pre- - cedence. For example, - - - -Version 2.5 Last change: April 1995 7 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - foo|bar* - - is the same as - - (foo)|(ba(r*)) - - since the '*' operator has higher precedence than concatena- - tion, and concatenation higher than alternation ('|'). This - pattern therefore matches either the string "foo" or the - string "ba" followed by zero-or-more r's. To match "foo" or - zero-or-more "bar"'s, use: - - foo|(bar)* - - and to match zero-or-more "foo"'s-or-"bar"'s: - - (foo|bar)* - - - In addition to characters and ranges of characters, charac- - ter classes can also contain character class expressions. - These are expressions enclosed inside [: and :] delimiters - (which themselves must appear between the '[' and ']' of the - character class; other elements may occur inside the charac- - ter class, too). The valid expressions are: - - [:alnum:] [:alpha:] [:blank:] - [:cntrl:] [:digit:] [:graph:] - [:lower:] [:print:] [:punct:] - [:space:] [:upper:] [:xdigit:] - - These expressions all designate a set of characters - equivalent to the corresponding standard C isXXX function. - For example, [:alnum:] designates those characters for which - isalnum() returns true - i.e., any alphabetic or numeric. - Some systems don't provide isblank(), so flex defines - [:blank:] as a blank or a tab. - - For example, the following character classes are all - equivalent: - - [[:alnum:]] - [[:alpha:][:digit:] - [[:alpha:]0-9] - [a-zA-Z0-9] - - If your scanner is case-insensitive (the -i flag), then - [:upper:] and [:lower:] are equivalent to [:alpha:]. - - Some notes on patterns: - - - A negated character class such as the example "[^A-Z]" - - - -Version 2.5 Last change: April 1995 8 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - above will match a newline unless "\n" (or an - equivalent escape sequence) is one of the characters - explicitly present in the negated character class - (e.g., "[^A-Z\n]"). This is unlike how many other reg- - ular expression tools treat negated character classes, - but unfortunately the inconsistency is historically - entrenched. Matching newlines means that a pattern - like [^"]* can match the entire input unless there's - another quote in the input. - - - A rule can have at most one instance of trailing con- - text (the '/' operator or the '$' operator). The start - condition, '^', and "<>" patterns can only occur - at the beginning of a pattern, and, as well as with '/' - and '$', cannot be grouped inside parentheses. A '^' - which does not occur at the beginning of a rule or a - '$' which does not occur at the end of a rule loses its - special properties and is treated as a normal charac- - ter. - - The following are illegal: - - foo/bar$ - foobar - - Note that the first of these, can be written - "foo/bar\n". - - The following will result in '$' or '^' being treated - as a normal character: - - foo|(bar$) - foo|^bar - - If what's wanted is a "foo" or a bar-followed-by-a- - newline, the following could be used (the special '|' - action is explained below): - - foo | - bar$ /* action goes here */ - - A similar trick will work for matching a foo or a bar- - at-the-beginning-of-a-line. - -HOW THE INPUT IS MATCHED - When the generated scanner is run, it analyzes its input - looking for strings which match any of its patterns. If it - finds more than one match, it takes the one matching the - most text (for trailing context rules, this includes the - length of the trailing part, even though it will then be - returned to the input). If it finds two or more matches of - the same length, the rule listed first in the flex input - - - -Version 2.5 Last change: April 1995 9 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - file is chosen. - - Once the match is determined, the text corresponding to the - match (called the token) is made available in the global - character pointer yytext, and its length in the global - integer yyleng. The action corresponding to the matched pat- - tern is then executed (a more detailed description of - actions follows), and then the remaining input is scanned - for another match. - - If no match is found, then the default rule is executed: the - next character in the input is considered matched and copied - to the standard output. Thus, the simplest legal flex input - is: - - %% - - which generates a scanner that simply copies its input (one - character at a time) to its output. - - Note that yytext can be defined in two different ways: - either as a character pointer or as a character array. You - can control which definition flex uses by including one of - the special directives %pointer or %array in the first - (definitions) section of your flex input. The default is - %pointer, unless you use the -l lex compatibility option, in - which case yytext will be an array. The advantage of using - %pointer is substantially faster scanning and no buffer - overflow when matching very large tokens (unless you run out - of dynamic memory). The disadvantage is that you are res- - tricted in how your actions can modify yytext (see the next - section), and calls to the unput() function destroys the - present contents of yytext, which can be a considerable - porting headache when moving between different lex versions. - - The advantage of %array is that you can then modify yytext - to your heart's content, and calls to unput() do not destroy - yytext (see below). Furthermore, existing lex programs - sometimes access yytext externally using declarations of the - form: - extern char yytext[]; - This definition is erroneous when used with %pointer, but - correct for %array. - - %array defines yytext to be an array of YYLMAX characters, - which defaults to a fairly large value. You can change the - size by simply #define'ing YYLMAX to a different value in - the first section of your flex input. As mentioned above, - with %pointer yytext grows dynamically to accommodate large - tokens. While this means your %pointer scanner can accommo- - date very large tokens (such as matching entire blocks of - comments), bear in mind that each time the scanner must - - - -Version 2.5 Last change: April 1995 10 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - resize yytext it also must rescan the entire token from the - beginning, so matching such tokens can prove slow. yytext - presently does not dynamically grow if a call to unput() - results in too much text being pushed back; instead, a run- - time error results. - - Also note that you cannot use %array with C++ scanner - classes (the c++ option; see below). - -ACTIONS - Each pattern in a rule has a corresponding action, which can - be any arbitrary C statement. The pattern ends at the first - non-escaped whitespace character; the remainder of the line - is its action. If the action is empty, then when the pat- - tern is matched the input token is simply discarded. For - example, here is the specification for a program which - deletes all occurrences of "zap me" from its input: - - %% - "zap me" - - (It will copy all other characters in the input to the out- - put since they will be matched by the default rule.) - - Here is a program which compresses multiple blanks and tabs - down to a single blank, and throws away whitespace found at - the end of a line: - - %% - [ \t]+ putchar( ' ' ); - [ \t]+$ /* ignore this token */ - - - If the action contains a '{', then the action spans till the - balancing '}' is found, and the action may cross multiple - lines. flex knows about C strings and comments and won't be - fooled by braces found within them, but also allows actions - to begin with %{ and will consider the action to be all the - text up to the next %} (regardless of ordinary braces inside - the action). - - An action consisting solely of a vertical bar ('|') means - "same as the action for the next rule." See below for an - illustration. - - Actions can include arbitrary C code, including return - statements to return a value to whatever routine called - yylex(). Each time yylex() is called it continues processing - tokens from where it last left off until it either reaches - the end of the file or executes a return. - - - - - -Version 2.5 Last change: April 1995 11 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - Actions are free to modify yytext except for lengthening it - (adding characters to its end--these will overwrite later - characters in the input stream). This however does not - apply when using %array (see above); in that case, yytext - may be freely modified in any way. - - Actions are free to modify yyleng except they should not do - so if the action also includes use of yymore() (see below). - - There are a number of special directives which can be - included within an action: - - - ECHO copies yytext to the scanner's output. - - - BEGIN followed by the name of a start condition places - the scanner in the corresponding start condition (see - below). - - - REJECT directs the scanner to proceed on to the "second - best" rule which matched the input (or a prefix of the - input). The rule is chosen as described above in "How - the Input is Matched", and yytext and yyleng set up - appropriately. It may either be one which matched as - much text as the originally chosen rule but came later - in the flex input file, or one which matched less text. - For example, the following will both count the words in - the input and call the routine special() whenever - "frob" is seen: - - int word_count = 0; - %% - - frob special(); REJECT; - [^ \t\n]+ ++word_count; - - Without the REJECT, any "frob"'s in the input would not - be counted as words, since the scanner normally exe- - cutes only one action per token. Multiple REJECT's are - allowed, each one finding the next best choice to the - currently active rule. For example, when the following - scanner scans the token "abcd", it will write "abcdab- - caba" to the output: - - %% - a | - ab | - abc | - abcd ECHO; REJECT; - .|\n /* eat up any unmatched character */ - - (The first three rules share the fourth's action since - they use the special '|' action.) REJECT is a - - - -Version 2.5 Last change: April 1995 12 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - particularly expensive feature in terms of scanner per- - formance; if it is used in any of the scanner's actions - it will slow down all of the scanner's matching. - Furthermore, REJECT cannot be used with the -Cf or -CF - options (see below). - - Note also that unlike the other special actions, REJECT - is a branch; code immediately following it in the - action will not be executed. - - - yymore() tells the scanner that the next time it - matches a rule, the corresponding token should be - appended onto the current value of yytext rather than - replacing it. For example, given the input "mega- - kludge" the following will write "mega-mega-kludge" to - the output: - - %% - mega- ECHO; yymore(); - kludge ECHO; - - First "mega-" is matched and echoed to the output. - Then "kludge" is matched, but the previous "mega-" is - still hanging around at the beginning of yytext so the - ECHO for the "kludge" rule will actually write "mega- - kludge". - - Two notes regarding use of yymore(). First, yymore() depends - on the value of yyleng correctly reflecting the size of the - current token, so you must not modify yyleng if you are - using yymore(). Second, the presence of yymore() in the - scanner's action entails a minor performance penalty in the - scanner's matching speed. - - - yyless(n) returns all but the first n characters of the - current token back to the input stream, where they will - be rescanned when the scanner looks for the next match. - yytext and yyleng are adjusted appropriately (e.g., - yyleng will now be equal to n ). For example, on the - input "foobar" the following will write out "foobar- - bar": - - %% - foobar ECHO; yyless(3); - [a-z]+ ECHO; - - An argument of 0 to yyless will cause the entire - current input string to be scanned again. Unless - you've changed how the scanner will subsequently pro- - cess its input (using BEGIN, for example), this will - result in an endless loop. - - - - -Version 2.5 Last change: April 1995 13 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - Note that yyless is a macro and can only be used in the flex - input file, not from other source files. - - - unput(c) puts the character c back onto the input - stream. It will be the next character scanned. The - following action will take the current token and cause - it to be rescanned enclosed in parentheses. - - { - int i; - /* Copy yytext because unput() trashes yytext */ - char *yycopy = strdup( yytext ); - unput( ')' ); - for ( i = yyleng - 1; i >= 0; --i ) - unput( yycopy[i] ); - unput( '(' ); - free( yycopy ); - } - - Note that since each unput() puts the given character - back at the beginning of the input stream, pushing back - strings must be done back-to-front. - - An important potential problem when using unput() is that if - you are using %pointer (the default), a call to unput() des- - troys the contents of yytext, starting with its rightmost - character and devouring one character to the left with each - call. If you need the value of yytext preserved after a - call to unput() (as in the above example), you must either - first copy it elsewhere, or build your scanner using %array - instead (see How The Input Is Matched). - - Finally, note that you cannot put back EOF to attempt to - mark the input stream with an end-of-file. - - - input() reads the next character from the input stream. - For example, the following is one way to eat up C com- - ments: - - %% - "/*" { - register int c; - - for ( ; ; ) - { - while ( (c = input()) != '*' && - c != EOF ) - ; /* eat up text of comment */ - - if ( c == '*' ) - { - while ( (c = input()) == '*' ) - - - -Version 2.5 Last change: April 1995 14 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - ; - if ( c == '/' ) - break; /* found the end */ - } - - if ( c == EOF ) - { - error( "EOF in comment" ); - break; - } - } - } - - (Note that if the scanner is compiled using C++, then - input() is instead referred to as yyinput(), in order - to avoid a name clash with the C++ stream by the name - of input.) - - - YY_FLUSH_BUFFER flushes the scanner's internal buffer - so that the next time the scanner attempts to match a - token, it will first refill the buffer using YY_INPUT - (see The Generated Scanner, below). This action is a - special case of the more general yy_flush_buffer() - function, described below in the section Multiple Input - Buffers. - - - yyterminate() can be used in lieu of a return statement - in an action. It terminates the scanner and returns a - 0 to the scanner's caller, indicating "all done". By - default, yyterminate() is also called when an end-of- - file is encountered. It is a macro and may be rede- - fined. - -THE GENERATED SCANNER - The output of flex is the file lex.yy.c, which contains the - scanning routine yylex(), a number of tables used by it for - matching tokens, and a number of auxiliary routines and mac- - ros. By default, yylex() is declared as follows: - - int yylex() - { - ... various definitions and the actions in here ... - } - - (If your environment supports function prototypes, then it - will be "int yylex( void )".) This definition may be - changed by defining the "YY_DECL" macro. For example, you - could use: - - #define YY_DECL float lexscan( a, b ) float a, b; - - to give the scanning routine the name lexscan, returning a - - - -Version 2.5 Last change: April 1995 15 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - float, and taking two floats as arguments. Note that if you - give arguments to the scanning routine using a K&R- - style/non-prototyped function declaration, you must ter- - minate the definition with a semi-colon (;). - - Whenever yylex() is called, it scans tokens from the global - input file yyin (which defaults to stdin). It continues - until it either reaches an end-of-file (at which point it - returns the value 0) or one of its actions executes a return - statement. - - If the scanner reaches an end-of-file, subsequent calls are - undefined unless either yyin is pointed at a new input file - (in which case scanning continues from that file), or yyres- - tart() is called. yyrestart() takes one argument, a FILE * - pointer (which can be nil, if you've set up YY_INPUT to scan - from a source other than yyin), and initializes yyin for - scanning from that file. Essentially there is no difference - between just assigning yyin to a new input file or using - yyrestart() to do so; the latter is available for compati- - bility with previous versions of flex, and because it can be - used to switch input files in the middle of scanning. It - can also be used to throw away the current input buffer, by - calling it with an argument of yyin; but better is to use - YY_FLUSH_BUFFER (see above). Note that yyrestart() does not - reset the start condition to INITIAL (see Start Conditions, - below). - - If yylex() stops scanning due to executing a return state- - ment in one of the actions, the scanner may then be called - again and it will resume scanning where it left off. - - By default (and for purposes of efficiency), the scanner - uses block-reads rather than simple getc() calls to read - characters from yyin. The nature of how it gets its input - can be controlled by defining the YY_INPUT macro. - YY_INPUT's calling sequence is - "YY_INPUT(buf,result,max_size)". Its action is to place up - to max_size characters in the character array buf and return - in the integer variable result either the number of charac- - ters read or the constant YY_NULL (0 on Unix systems) to - indicate EOF. The default YY_INPUT reads from the global - file-pointer "yyin". - - A sample definition of YY_INPUT (in the definitions section - of the input file): - - %{ - #define YY_INPUT(buf,result,max_size) \ - { \ - int c = getchar(); \ - result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \ - - - -Version 2.5 Last change: April 1995 16 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - } - %} - - This definition will change the input processing to occur - one character at a time. - - When the scanner receives an end-of-file indication from - YY_INPUT, it then checks the yywrap() function. If yywrap() - returns false (zero), then it is assumed that the function - has gone ahead and set up yyin to point to another input - file, and scanning continues. If it returns true (non- - zero), then the scanner terminates, returning 0 to its - caller. Note that in either case, the start condition - remains unchanged; it does not revert to INITIAL. - - If you do not supply your own version of yywrap(), then you - must either use %option noyywrap (in which case the scanner - behaves as though yywrap() returned 1), or you must link - with -lfl to obtain the default version of the routine, - which always returns 1. - - Three routines are available for scanning from in-memory - buffers rather than files: yy_scan_string(), - yy_scan_bytes(), and yy_scan_buffer(). See the discussion of - them below in the section Multiple Input Buffers. - - The scanner writes its ECHO output to the yyout global - (default, stdout), which may be redefined by the user simply - by assigning it to some other FILE pointer. - -START CONDITIONS - flex provides a mechanism for conditionally activating - rules. Any rule whose pattern is prefixed with "" will - only be active when the scanner is in the start condition - named "sc". For example, - - [^"]* { /* eat up the string body ... */ - ... - } - - will be active only when the scanner is in the "STRING" - start condition, and - - \. { /* handle an escape ... */ - ... - } - - will be active only when the current start condition is - either "INITIAL", "STRING", or "QUOTE". - - Start conditions are declared in the definitions (first) - section of the input using unindented lines beginning with - - - -Version 2.5 Last change: April 1995 17 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - either %s or %x followed by a list of names. The former - declares inclusive start conditions, the latter exclusive - start conditions. A start condition is activated using the - BEGIN action. Until the next BEGIN action is executed, - rules with the given start condition will be active and - rules with other start conditions will be inactive. If the - start condition is inclusive, then rules with no start con- - ditions at all will also be active. If it is exclusive, - then only rules qualified with the start condition will be - active. A set of rules contingent on the same exclusive - start condition describe a scanner which is independent of - any of the other rules in the flex input. Because of this, - exclusive start conditions make it easy to specify "mini- - scanners" which scan portions of the input that are syntac- - tically different from the rest (e.g., comments). - - If the distinction between inclusive and exclusive start - conditions is still a little vague, here's a simple example - illustrating the connection between the two. The set of - rules: - - %s example - %% - - foo do_something(); - - bar something_else(); - - is equivalent to - - %x example - %% - - foo do_something(); - - bar something_else(); - - Without the qualifier, the bar pattern in - the second example wouldn't be active (i.e., couldn't match) - when in start condition example. If we just used - to qualify bar, though, then it would only be active in - example and not in INITIAL, while in the first example it's - active in both, because in the first example the example - startion condition is an inclusive (%s) start condition. - - Also note that the special start-condition specifier <*> - matches every start condition. Thus, the above example - could also have been written; - - %x example - %% - - - - -Version 2.5 Last change: April 1995 18 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - foo do_something(); - - <*>bar something_else(); - - - The default rule (to ECHO any unmatched character) remains - active in start conditions. It is equivalent to: - - <*>.|\n ECHO; - - - BEGIN(0) returns to the original state where only the rules - with no start conditions are active. This state can also be - referred to as the start-condition "INITIAL", so - BEGIN(INITIAL) is equivalent to BEGIN(0). (The parentheses - around the start condition name are not required but are - considered good style.) - - BEGIN actions can also be given as indented code at the - beginning of the rules section. For example, the following - will cause the scanner to enter the "SPECIAL" start condi- - tion whenever yylex() is called and the global variable - enter_special is true: - - int enter_special; - - %x SPECIAL - %% - if ( enter_special ) - BEGIN(SPECIAL); - - blahblahblah - ...more rules follow... - - - To illustrate the uses of start conditions, here is a - scanner which provides two different interpretations of a - string like "123.456". By default it will treat it as three - tokens, the integer "123", a dot ('.'), and the integer - "456". But if the string is preceded earlier in the line by - the string "expect-floats" it will treat it as a single - token, the floating-point number 123.456: - - %{ - #include - %} - %s expect - - %% - expect-floats BEGIN(expect); - - [0-9]+"."[0-9]+ { - - - -Version 2.5 Last change: April 1995 19 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - printf( "found a float, = %f\n", - atof( yytext ) ); - } - \n { - /* that's the end of the line, so - * we need another "expect-number" - * before we'll recognize any more - * numbers - */ - BEGIN(INITIAL); - } - - [0-9]+ { - printf( "found an integer, = %d\n", - atoi( yytext ) ); - } - - "." printf( "found a dot\n" ); - - Here is a scanner which recognizes (and discards) C comments - while maintaining a count of the current input line. - - %x comment - %% - int line_num = 1; - - "/*" BEGIN(comment); - - [^*\n]* /* eat anything that's not a '*' */ - "*"+[^*/\n]* /* eat up '*'s not followed by '/'s */ - \n ++line_num; - "*"+"/" BEGIN(INITIAL); - - This scanner goes to a bit of trouble to match as much text - as possible with each rule. In general, when attempting to - write a high-speed scanner try to match as much possible in - each rule, as it's a big win. - - Note that start-conditions names are really integer values - and can be stored as such. Thus, the above could be - extended in the following fashion: - - %x comment foo - %% - int line_num = 1; - int comment_caller; - - "/*" { - comment_caller = INITIAL; - BEGIN(comment); - } - - - - -Version 2.5 Last change: April 1995 20 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - ... - - "/*" { - comment_caller = foo; - BEGIN(comment); - } - - [^*\n]* /* eat anything that's not a '*' */ - "*"+[^*/\n]* /* eat up '*'s not followed by '/'s */ - \n ++line_num; - "*"+"/" BEGIN(comment_caller); - - Furthermore, you can access the current start condition - using the integer-valued YY_START macro. For example, the - above assignments to comment_caller could instead be written - - comment_caller = YY_START; - - Flex provides YYSTATE as an alias for YY_START (since that - is what's used by AT&T lex). - - Note that start conditions do not have their own name-space; - %s's and %x's declare names in the same fashion as - #define's. - - Finally, here's an example of how to match C-style quoted - strings using exclusive start conditions, including expanded - escape sequences (but not including checking for a string - that's too long): - - %x str - - %% - char string_buf[MAX_STR_CONST]; - char *string_buf_ptr; - - - \" string_buf_ptr = string_buf; BEGIN(str); - - \" { /* saw closing quote - all done */ - BEGIN(INITIAL); - *string_buf_ptr = '\0'; - /* return string constant token type and - * value to parser - */ - } - - \n { - /* error - unterminated string constant */ - /* generate error message */ - } - - - - -Version 2.5 Last change: April 1995 21 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - \\[0-7]{1,3} { - /* octal escape sequence */ - int result; - - (void) sscanf( yytext + 1, "%o", &result ); - - if ( result > 0xff ) - /* error, constant is out-of-bounds */ - - *string_buf_ptr++ = result; - } - - \\[0-9]+ { - /* generate error - bad escape sequence; something - * like '\48' or '\0777777' - */ - } - - \\n *string_buf_ptr++ = '\n'; - \\t *string_buf_ptr++ = '\t'; - \\r *string_buf_ptr++ = '\r'; - \\b *string_buf_ptr++ = '\b'; - \\f *string_buf_ptr++ = '\f'; - - \\(.|\n) *string_buf_ptr++ = yytext[1]; - - [^\\\n\"]+ { - char *yptr = yytext; - - while ( *yptr ) - *string_buf_ptr++ = *yptr++; - } - - - Often, such as in some of the examples above, you wind up - writing a whole bunch of rules all preceded by the same - start condition(s). Flex makes this a little easier and - cleaner by introducing a notion of start condition scope. A - start condition scope is begun with: - - { - - where SCs is a list of one or more start conditions. Inside - the start condition scope, every rule automatically has the - prefix applied to it, until a '}' which matches the - initial '{'. So, for example, - - { - "\\n" return '\n'; - "\\r" return '\r'; - "\\f" return '\f'; - "\\0" return '\0'; - - - -Version 2.5 Last change: April 1995 22 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - } - - is equivalent to: - - "\\n" return '\n'; - "\\r" return '\r'; - "\\f" return '\f'; - "\\0" return '\0'; - - Start condition scopes may be nested. - - Three routines are available for manipulating stacks of - start conditions: - - void yy_push_state(int new_state) - pushes the current start condition onto the top of the - start condition stack and switches to new_state as - though you had used BEGIN new_state (recall that start - condition names are also integers). - - void yy_pop_state() - pops the top of the stack and switches to it via BEGIN. - - int yy_top_state() - returns the top of the stack without altering the - stack's contents. - - The start condition stack grows dynamically and so has no - built-in size limitation. If memory is exhausted, program - execution aborts. - - To use start condition stacks, your scanner must include a - %option stack directive (see Options below). - -MULTIPLE INPUT BUFFERS - Some scanners (such as those which support "include" files) - require reading from several input streams. As flex - scanners do a large amount of buffering, one cannot control - where the next input will be read from by simply writing a - YY_INPUT which is sensitive to the scanning context. - YY_INPUT is only called when the scanner reaches the end of - its buffer, which may be a long time after scanning a state- - ment such as an "include" which requires switching the input - source. - - To negotiate these sorts of problems, flex provides a - mechanism for creating and switching between multiple input - buffers. An input buffer is created by using: - - YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) - - which takes a FILE pointer and a size and creates a buffer - - - -Version 2.5 Last change: April 1995 23 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - associated with the given file and large enough to hold size - characters (when in doubt, use YY_BUF_SIZE for the size). - It returns a YY_BUFFER_STATE handle, which may then be - passed to other routines (see below). The YY_BUFFER_STATE - type is a pointer to an opaque struct yy_buffer_state struc- - ture, so you may safely initialize YY_BUFFER_STATE variables - to ((YY_BUFFER_STATE) 0) if you wish, and also refer to the - opaque structure in order to correctly declare input buffers - in source files other than that of your scanner. Note that - the FILE pointer in the call to yy_create_buffer is only - used as the value of yyin seen by YY_INPUT; if you redefine - YY_INPUT so it no longer uses yyin, then you can safely pass - a nil FILE pointer to yy_create_buffer. You select a partic- - ular buffer to scan from using: - - void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) - - switches the scanner's input buffer so subsequent tokens - will come from new_buffer. Note that yy_switch_to_buffer() - may be used by yywrap() to set things up for continued scan- - ning, instead of opening a new file and pointing yyin at it. - Note also that switching input sources via either - yy_switch_to_buffer() or yywrap() does not change the start - condition. - - void yy_delete_buffer( YY_BUFFER_STATE buffer ) - - is used to reclaim the storage associated with a buffer. ( - buffer can be nil, in which case the routine does nothing.) - You can also clear the current contents of a buffer using: - - void yy_flush_buffer( YY_BUFFER_STATE buffer ) - - This function discards the buffer's contents, so the next - time the scanner attempts to match a token from the buffer, - it will first fill the buffer anew using YY_INPUT. - - yy_new_buffer() is an alias for yy_create_buffer(), provided - for compatibility with the C++ use of new and delete for - creating and destroying dynamic objects. - - Finally, the YY_CURRENT_BUFFER macro returns a - YY_BUFFER_STATE handle to the current buffer. - - Here is an example of using these features for writing a - scanner which expands include files (the <> feature is - discussed below): - - /* the "incl" state is used for picking up the name - * of an include file - */ - %x incl - - - -Version 2.5 Last change: April 1995 24 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - %{ - #define MAX_INCLUDE_DEPTH 10 - YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH]; - int include_stack_ptr = 0; - %} - - %% - include BEGIN(incl); - - [a-z]+ ECHO; - [^a-z\n]*\n? ECHO; - - [ \t]* /* eat the whitespace */ - [^ \t\n]+ { /* got the include file name */ - if ( include_stack_ptr >= MAX_INCLUDE_DEPTH ) - { - fprintf( stderr, "Includes nested too deeply" ); - exit( 1 ); - } - - include_stack[include_stack_ptr++] = - YY_CURRENT_BUFFER; - - yyin = fopen( yytext, "r" ); - - if ( ! yyin ) - error( ... ); - - yy_switch_to_buffer( - yy_create_buffer( yyin, YY_BUF_SIZE ) ); - - BEGIN(INITIAL); - } - - <> { - if ( --include_stack_ptr < 0 ) - { - yyterminate(); - } - - else - { - yy_delete_buffer( YY_CURRENT_BUFFER ); - yy_switch_to_buffer( - include_stack[include_stack_ptr] ); - } - } - - Three routines are available for setting up input buffers - for scanning in-memory strings instead of files. All of - them create a new input buffer for scanning the string, and - return a corresponding YY_BUFFER_STATE handle (which you - - - -Version 2.5 Last change: April 1995 25 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - should delete with yy_delete_buffer() when done with it). - They also switch to the new buffer using - yy_switch_to_buffer(), so the next call to yylex() will - start scanning the string. - - yy_scan_string(const char *str) - scans a NUL-terminated string. - - yy_scan_bytes(const char *bytes, int len) - scans len bytes (including possibly NUL's) starting at - location bytes. - - Note that both of these functions create and scan a copy of - the string or bytes. (This may be desirable, since yylex() - modifies the contents of the buffer it is scanning.) You - can avoid the copy by using: - - yy_scan_buffer(char *base, yy_size_t size) - which scans in place the buffer starting at base, con- - sisting of size bytes, the last two bytes of which must - be YY_END_OF_BUFFER_CHAR (ASCII NUL). These last two - bytes are not scanned; thus, scanning consists of - base[0] through base[size-2], inclusive. - - If you fail to set up base in this manner (i.e., forget - the final two YY_END_OF_BUFFER_CHAR bytes), then - yy_scan_buffer() returns a nil pointer instead of - creating a new input buffer. - - The type yy_size_t is an integral type to which you can - cast an integer expression reflecting the size of the - buffer. - -END-OF-FILE RULES - The special rule "<>" indicates actions which are to be - taken when an end-of-file is encountered and yywrap() - returns non-zero (i.e., indicates no further files to pro- - cess). The action must finish by doing one of four things: - - - assigning yyin to a new input file (in previous ver- - sions of flex, after doing the assignment you had to - call the special action YY_NEW_FILE; this is no longer - necessary); - - - executing a return statement; - - - executing the special yyterminate() action; - - - or, switching to a new buffer using - yy_switch_to_buffer() as shown in the example above. - - - - - -Version 2.5 Last change: April 1995 26 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - <> rules may not be used with other patterns; they may - only be qualified with a list of start conditions. If an - unqualified <> rule is given, it applies to all start - conditions which do not already have <> actions. To - specify an <> rule for only the initial start condi- - tion, use - - <> - - - These rules are useful for catching things like unclosed - comments. An example: - - %x quote - %% - - ...other rules for dealing with quotes... - - <> { - error( "unterminated quote" ); - yyterminate(); - } - <> { - if ( *++filelist ) - yyin = fopen( *filelist, "r" ); - else - yyterminate(); - } - - -MISCELLANEOUS MACROS - The macro YY_USER_ACTION can be defined to provide an action - which is always executed prior to the matched rule's action. - For example, it could be #define'd to call a routine to con- - vert yytext to lower-case. When YY_USER_ACTION is invoked, - the variable yy_act gives the number of the matched rule - (rules are numbered starting with 1). Suppose you want to - profile how often each of your rules is matched. The fol- - lowing would do the trick: - - #define YY_USER_ACTION ++ctr[yy_act] - - where ctr is an array to hold the counts for the different - rules. Note that the macro YY_NUM_RULES gives the total - number of rules (including the default rule, even if you use - -s), so a correct declaration for ctr is: - - int ctr[YY_NUM_RULES]; - - - The macro YY_USER_INIT may be defined to provide an action - which is always executed before the first scan (and before - - - -Version 2.5 Last change: April 1995 27 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - the scanner's internal initializations are done). For exam- - ple, it could be used to call a routine to read in a data - table or open a logging file. - - The macro yy_set_interactive(is_interactive) can be used to - control whether the current buffer is considered interac- - tive. An interactive buffer is processed more slowly, but - must be used when the scanner's input source is indeed - interactive to avoid problems due to waiting to fill buffers - (see the discussion of the -I flag below). A non-zero value - in the macro invocation marks the buffer as interactive, a - zero value as non-interactive. Note that use of this macro - overrides %option always-interactive or %option never- - interactive (see Options below). yy_set_interactive() must - be invoked prior to beginning to scan the buffer that is (or - is not) to be considered interactive. - - The macro yy_set_bol(at_bol) can be used to control whether - the current buffer's scanning context for the next token - match is done as though at the beginning of a line. A non- - zero macro argument makes rules anchored with - - The macro YY_AT_BOL() returns true if the next token scanned - from the current buffer will have '^' rules active, false - otherwise. - - In the generated scanner, the actions are all gathered in - one large switch statement and separated using YY_BREAK, - which may be redefined. By default, it is simply a "break", - to separate each rule's action from the following rule's. - Redefining YY_BREAK allows, for example, C++ users to - #define YY_BREAK to do nothing (while being very careful - that every rule ends with a "break" or a "return"!) to avoid - suffering from unreachable statement warnings where because - a rule's action ends with "return", the YY_BREAK is inacces- - sible. - -VALUES AVAILABLE TO THE USER - This section summarizes the various values available to the - user in the rule actions. - - - char *yytext holds the text of the current token. It - may be modified but not lengthened (you cannot append - characters to the end). - - If the special directive %array appears in the first - section of the scanner description, then yytext is - instead declared char yytext[YYLMAX], where YYLMAX is a - macro definition that you can redefine in the first - section if you don't like the default value (generally - 8KB). Using %array results in somewhat slower - scanners, but the value of yytext becomes immune to - - - -Version 2.5 Last change: April 1995 28 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - calls to input() and unput(), which potentially destroy - its value when yytext is a character pointer. The - opposite of %array is %pointer, which is the default. - - You cannot use %array when generating C++ scanner - classes (the -+ flag). - - - int yyleng holds the length of the current token. - - - FILE *yyin is the file which by default flex reads - from. It may be redefined but doing so only makes - sense before scanning begins or after an EOF has been - encountered. Changing it in the midst of scanning will - have unexpected results since flex buffers its input; - use yyrestart() instead. Once scanning terminates - because an end-of-file has been seen, you can assign - yyin at the new input file and then call the scanner - again to continue scanning. - - - void yyrestart( FILE *new_file ) may be called to point - yyin at the new input file. The switch-over to the new - file is immediate (any previously buffered-up input is - lost). Note that calling yyrestart() with yyin as an - argument thus throws away the current input buffer and - continues scanning the same input file. - - - FILE *yyout is the file to which ECHO actions are done. - It can be reassigned by the user. - - - YY_CURRENT_BUFFER returns a YY_BUFFER_STATE handle to - the current buffer. - - - YY_START returns an integer value corresponding to the - current start condition. You can subsequently use this - value with BEGIN to return to that start condition. - -INTERFACING WITH YACC - One of the main uses of flex is as a companion to the yacc - parser-generator. yacc parsers expect to call a routine - named yylex() to find the next input token. The routine is - supposed to return the type of the next token as well as - putting any associated value in the global yylval. To use - flex with yacc, one specifies the -d option to yacc to - instruct it to generate the file y.tab.h containing defini- - tions of all the %tokens appearing in the yacc input. This - file is then included in the flex scanner. For example, if - one of the tokens is "TOK_NUMBER", part of the scanner might - look like: - - %{ - #include "y.tab.h" - %} - - - -Version 2.5 Last change: April 1995 29 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - %% - - [0-9]+ yylval = atoi( yytext ); return TOK_NUMBER; - - -OPTIONS - flex has the following options: - - -b Generate backing-up information to lex.backup. This is - a list of scanner states which require backing up and - the input characters on which they do so. By adding - rules one can remove backing-up states. If all - backing-up states are eliminated and -Cf or -CF is - used, the generated scanner will run faster (see the -p - flag). Only users who wish to squeeze every last cycle - out of their scanners need worry about this option. - (See the section on Performance Considerations below.) - - -c is a do-nothing, deprecated option included for POSIX - compliance. - - -d makes the generated scanner run in debug mode. When- - ever a pattern is recognized and the global - yy_flex_debug is non-zero (which is the default), the - scanner will write to stderr a line of the form: - - --accepting rule at line 53 ("the matched text") - - The line number refers to the location of the rule in - the file defining the scanner (i.e., the file that was - fed to flex). Messages are also generated when the - scanner backs up, accepts the default rule, reaches the - end of its input buffer (or encounters a NUL; at this - point, the two look the same as far as the scanner's - concerned), or reaches an end-of-file. - - -f specifies fast scanner. No table compression is done - and stdio is bypassed. The result is large but fast. - This option is equivalent to -Cfr (see below). - - -h generates a "help" summary of flex's options to stdout - and then exits. -? and --help are synonyms for -h. - - -i instructs flex to generate a case-insensitive scanner. - The case of letters given in the flex input patterns - will be ignored, and tokens in the input will be - matched regardless of case. The matched text given in - yytext will have the preserved case (i.e., it will not - be folded). - - -l turns on maximum compatibility with the original AT&T - lex implementation. Note that this does not mean full - - - -Version 2.5 Last change: April 1995 30 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - compatibility. Use of this option costs a considerable - amount of performance, and it cannot be used with the - -+, -f, -F, -Cf, or -CF options. For details on the - compatibilities it provides, see the section "Incompa- - tibilities With Lex And POSIX" below. This option also - results in the name YY_FLEX_LEX_COMPAT being #define'd - in the generated scanner. - - -n is another do-nothing, deprecated option included only - for POSIX compliance. - - -p generates a performance report to stderr. The report - consists of comments regarding features of the flex - input file which will cause a serious loss of perfor- - mance in the resulting scanner. If you give the flag - twice, you will also get comments regarding features - that lead to minor performance losses. - - Note that the use of REJECT, %option yylineno, and - variable trailing context (see the Deficiencies / Bugs - section below) entails a substantial performance - penalty; use of yymore(), the ^ operator, and the -I - flag entail minor performance penalties. - - -s causes the default rule (that unmatched scanner input - is echoed to stdout) to be suppressed. If the scanner - encounters input that does not match any of its rules, - it aborts with an error. This option is useful for - finding holes in a scanner's rule set. - - -t instructs flex to write the scanner it generates to - standard output instead of lex.yy.c. - - -v specifies that flex should write to stderr a summary of - statistics regarding the scanner it generates. Most of - the statistics are meaningless to the casual flex user, - but the first line identifies the version of flex (same - as reported by -V), and the next line the flags used - when generating the scanner, including those that are - on by default. - - -w suppresses warning messages. - - -B instructs flex to generate a batch scanner, the oppo- - site of interactive scanners generated by -I (see - below). In general, you use -B when you are certain - that your scanner will never be used interactively, and - you want to squeeze a little more performance out of - it. If your goal is instead to squeeze out a lot more - performance, you should be using the -Cf or -CF - options (discussed below), which turn on -B automati- - cally anyway. - - - -Version 2.5 Last change: April 1995 31 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - -F specifies that the fast scanner table representation - should be used (and stdio bypassed). This representa- - tion is about as fast as the full table representation - (-f), and for some sets of patterns will be consider- - ably smaller (and for others, larger). In general, if - the pattern set contains both "keywords" and a catch- - all, "identifier" rule, such as in the set: - - "case" return TOK_CASE; - "switch" return TOK_SWITCH; - ... - "default" return TOK_DEFAULT; - [a-z]+ return TOK_ID; - - then you're better off using the full table representa- - tion. If only the "identifier" rule is present and you - then use a hash table or some such to detect the key- - words, you're better off using -F. - - This option is equivalent to -CFr (see below). It can- - not be used with -+. - - -I instructs flex to generate an interactive scanner. An - interactive scanner is one that only looks ahead to - decide what token has been matched if it absolutely - must. It turns out that always looking one extra char- - acter ahead, even if the scanner has already seen - enough text to disambiguate the current token, is a bit - faster than only looking ahead when necessary. But - scanners that always look ahead give dreadful interac- - tive performance; for example, when a user types a new- - line, it is not recognized as a newline token until - they enter another token, which often means typing in - another whole line. - - Flex scanners default to interactive unless you use the - -Cf or -CF table-compression options (see below). - That's because if you're looking for high-performance - you should be using one of these options, so if you - didn't, flex assumes you'd rather trade off a bit of - run-time performance for intuitive interactive - behavior. Note also that you cannot use -I in conjunc- - tion with -Cf or -CF. Thus, this option is not really - needed; it is on by default for all those cases in - which it is allowed. - - You can force a scanner to not be interactive by using - -B (see above). - - -L instructs flex not to generate #line directives. - Without this option, flex peppers the generated scanner - with #line directives so error messages in the actions - - - -Version 2.5 Last change: April 1995 32 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - will be correctly located with respect to either the - original flex input file (if the errors are due to code - in the input file), or lex.yy.c (if the errors are - flex's fault -- you should report these sorts of errors - to the email address given below). - - -T makes flex run in trace mode. It will generate a lot - of messages to stderr concerning the form of the input - and the resultant non-deterministic and deterministic - finite automata. This option is mostly for use in - maintaining flex. - - -V prints the version number to stdout and exits. --ver- - sion is a synonym for -V. - - -7 instructs flex to generate a 7-bit scanner, i.e., one - which can only recognized 7-bit characters in its - input. The advantage of using -7 is that the scanner's - tables can be up to half the size of those generated - using the -8 option (see below). The disadvantage is - that such scanners often hang or crash if their input - contains an 8-bit character. - - Note, however, that unless you generate your scanner - using the -Cf or -CF table compression options, use of - -7 will save only a small amount of table space, and - make your scanner considerably less portable. Flex's - default behavior is to generate an 8-bit scanner unless - you use the -Cf or -CF, in which case flex defaults to - generating 7-bit scanners unless your site was always - configured to generate 8-bit scanners (as will often be - the case with non-USA sites). You can tell whether - flex generated a 7-bit or an 8-bit scanner by inspect- - ing the flag summary in the -v output as described - above. - - Note that if you use -Cfe or -CFe (those table compres- - sion options, but also using equivalence classes as - discussed see below), flex still defaults to generating - an 8-bit scanner, since usually with these compression - options full 8-bit tables are not much more expensive - than 7-bit tables. - - -8 instructs flex to generate an 8-bit scanner, i.e., one - which can recognize 8-bit characters. This flag is - only needed for scanners generated using -Cf or -CF, as - otherwise flex defaults to generating an 8-bit scanner - anyway. - - See the discussion of -7 above for flex's default - behavior and the tradeoffs between 7-bit and 8-bit - scanners. - - - -Version 2.5 Last change: April 1995 33 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - -+ specifies that you want flex to generate a C++ scanner - class. See the section on Generating C++ Scanners - below for details. - - -C[aefFmr] - controls the degree of table compression and, more gen- - erally, trade-offs between small scanners and fast - scanners. - - -Ca ("align") instructs flex to trade off larger tables - in the generated scanner for faster performance because - the elements of the tables are better aligned for - memory access and computation. On some RISC architec- - tures, fetching and manipulating longwords is more - efficient than with smaller-sized units such as short- - words. This option can double the size of the tables - used by your scanner. - - -Ce directs flex to construct equivalence classes, - i.e., sets of characters which have identical lexical - properties (for example, if the only appearance of - digits in the flex input is in the character class - "[0-9]" then the digits '0', '1', ..., '9' will all be - put in the same equivalence class). Equivalence - classes usually give dramatic reductions in the final - table/object file sizes (typically a factor of 2-5) and - are pretty cheap performance-wise (one array look-up - per character scanned). - - -Cf specifies that the full scanner tables should be - generated - flex should not compress the tables by tak- - ing advantages of similar transition functions for dif- - ferent states. - - -CF specifies that the alternate fast scanner represen- - tation (described above under the -F flag) should be - used. This option cannot be used with -+. - - -Cm directs flex to construct meta-equivalence classes, - which are sets of equivalence classes (or characters, - if equivalence classes are not being used) that are - commonly used together. Meta-equivalence classes are - often a big win when using compressed tables, but they - have a moderate performance impact (one or two "if" - tests and one array look-up per character scanned). - - -Cr causes the generated scanner to bypass use of the - standard I/O library (stdio) for input. Instead of - calling fread() or getc(), the scanner will use the - read() system call, resulting in a performance gain - which varies from system to system, but in general is - probably negligible unless you are also using -Cf or - - - -Version 2.5 Last change: April 1995 34 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - -CF. Using -Cr can cause strange behavior if, for exam- - ple, you read from yyin using stdio prior to calling - the scanner (because the scanner will miss whatever - text your previous reads left in the stdio input - buffer). - - -Cr has no effect if you define YY_INPUT (see The Gen- - erated Scanner above). - - A lone -C specifies that the scanner tables should be - compressed but neither equivalence classes nor meta- - equivalence classes should be used. - - The options -Cf or -CF and -Cm do not make sense - together - there is no opportunity for meta-equivalence - classes if the table is not being compressed. Other- - wise the options may be freely mixed, and are cumula- - tive. - - The default setting is -Cem, which specifies that flex - should generate equivalence classes and meta- - equivalence classes. This setting provides the highest - degree of table compression. You can trade off - faster-executing scanners at the cost of larger tables - with the following generally being true: - - slowest & smallest - -Cem - -Cm - -Ce - -C - -C{f,F}e - -C{f,F} - -C{f,F}a - fastest & largest - - Note that scanners with the smallest tables are usually - generated and compiled the quickest, so during develop- - ment you will usually want to use the default, maximal - compression. - - -Cfe is often a good compromise between speed and size - for production scanners. - - -ooutput - directs flex to write the scanner to the file output - instead of lex.yy.c. If you combine -o with the -t - option, then the scanner is written to stdout but its - #line directives (see the -L option above) refer to the - file output. - - -Pprefix - - - -Version 2.5 Last change: April 1995 35 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - changes the default yy prefix used by flex for all - globally-visible variable and function names to instead - be prefix. For example, -Pfoo changes the name of - yytext to footext. It also changes the name of the - default output file from lex.yy.c to lex.foo.c. Here - are all of the names affected: - - yy_create_buffer - yy_delete_buffer - yy_flex_debug - yy_init_buffer - yy_flush_buffer - yy_load_buffer_state - yy_switch_to_buffer - yyin - yyleng - yylex - yylineno - yyout - yyrestart - yytext - yywrap - - (If you are using a C++ scanner, then only yywrap and - yyFlexLexer are affected.) Within your scanner itself, - you can still refer to the global variables and func- - tions using either version of their name; but exter- - nally, they have the modified name. - - This option lets you easily link together multiple flex - programs into the same executable. Note, though, that - using this option also renames yywrap(), so you now - must either provide your own (appropriately-named) ver- - sion of the routine for your scanner, or use %option - noyywrap, as linking with -lfl no longer provides one - for you by default. - - -Sskeleton_file - overrides the default skeleton file from which flex - constructs its scanners. You'll never need this option - unless you are doing flex maintenance or development. - - flex also provides a mechanism for controlling options - within the scanner specification itself, rather than from - the flex command-line. This is done by including %option - directives in the first section of the scanner specifica- - tion. You can specify multiple options with a single - %option directive, and multiple directives in the first sec- - tion of your flex input file. - - Most options are given simply as names, optionally preceded - by the word "no" (with no intervening whitespace) to negate - - - -Version 2.5 Last change: April 1995 36 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - their meaning. A number are equivalent to flex flags or - their negation: - - 7bit -7 option - 8bit -8 option - align -Ca option - backup -b option - batch -B option - c++ -+ option - - caseful or - case-sensitive opposite of -i (default) - - case-insensitive or - caseless -i option - - debug -d option - default opposite of -s option - ecs -Ce option - fast -F option - full -f option - interactive -I option - lex-compat -l option - meta-ecs -Cm option - perf-report -p option - read -Cr option - stdout -t option - verbose -v option - warn opposite of -w option - (use "%option nowarn" for -w) - - array equivalent to "%array" - pointer equivalent to "%pointer" (default) - - Some %option's provide features otherwise not available: - - always-interactive - instructs flex to generate a scanner which always con- - siders its input "interactive". Normally, on each new - input file the scanner calls isatty() in an attempt to - determine whether the scanner's input source is - interactive and thus should be read a character at a - time. When this option is used, however, then no such - call is made. - - main directs flex to provide a default main() program for - the scanner, which simply calls yylex(). This option - implies noyywrap (see below). - - never-interactive - instructs flex to generate a scanner which never con- - siders its input "interactive" (again, no call made to - - - -Version 2.5 Last change: April 1995 37 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - isatty()). This is the opposite of always-interactive. - - stack - enables the use of start condition stacks (see Start - Conditions above). - - stdinit - if set (i.e., %option stdinit) initializes yyin and - yyout to stdin and stdout, instead of the default of - nil. Some existing lex programs depend on this - behavior, even though it is not compliant with ANSI C, - which does not require stdin and stdout to be compile- - time constant. - - yylineno - directs flex to generate a scanner that maintains the - number of the current line read from its input in the - global variable yylineno. This option is implied by - %option lex-compat. - - yywrap - if unset (i.e., %option noyywrap), makes the scanner - not call yywrap() upon an end-of-file, but simply - assume that there are no more files to scan (until the - user points yyin at a new file and calls yylex() - again). - - flex scans your rule actions to determine whether you use - the REJECT or yymore() features. The reject and yymore - options are available to override its decision as to whether - you use the options, either by setting them (e.g., %option - reject) to indicate the feature is indeed used, or unsetting - them to indicate it actually is not used (e.g., %option - noyymore). - - Three options take string-delimited values, offset with '=': - - %option outfile="ABC" - - is equivalent to -oABC, and - - %option prefix="XYZ" - - is equivalent to -PXYZ. Finally, - - %option yyclass="foo" - - only applies when generating a C++ scanner ( -+ option). It - informs flex that you have derived foo as a subclass of - yyFlexLexer, so flex will place your actions in the member - function foo::yylex() instead of yyFlexLexer::yylex(). It - also generates a yyFlexLexer::yylex() member function that - - - -Version 2.5 Last change: April 1995 38 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - emits a run-time error (by invoking - yyFlexLexer::LexerError()) if called. See Generating C++ - Scanners, below, for additional information. - - A number of options are available for lint purists who want - to suppress the appearance of unneeded routines in the gen- - erated scanner. Each of the following, if unset (e.g., - %option nounput ), results in the corresponding routine not - appearing in the generated scanner: - - input, unput - yy_push_state, yy_pop_state, yy_top_state - yy_scan_buffer, yy_scan_bytes, yy_scan_string - - (though yy_push_state() and friends won't appear anyway - unless you use %option stack). - -PERFORMANCE CONSIDERATIONS - The main design goal of flex is that it generate high- - performance scanners. It has been optimized for dealing - well with large sets of rules. Aside from the effects on - scanner speed of the table compression -C options outlined - above, there are a number of options/actions which degrade - performance. These are, from most expensive to least: - - REJECT - %option yylineno - arbitrary trailing context - - pattern sets that require backing up - %array - %option interactive - %option always-interactive - - '^' beginning-of-line operator - yymore() - - with the first three all being quite expensive and the last - two being quite cheap. Note also that unput() is imple- - mented as a routine call that potentially does quite a bit - of work, while yyless() is a quite-cheap macro; so if just - putting back some excess text you scanned, use yyless(). - - REJECT should be avoided at all costs when performance is - important. It is a particularly expensive option. - - Getting rid of backing up is messy and often may be an enor- - mous amount of work for a complicated scanner. In princi- - pal, one begins by using the -b flag to generate a - lex.backup file. For example, on the input - - %% - - - -Version 2.5 Last change: April 1995 39 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - foo return TOK_KEYWORD; - foobar return TOK_KEYWORD; - - the file looks like: - - State #6 is non-accepting - - associated rule line numbers: - 2 3 - out-transitions: [ o ] - jam-transitions: EOF [ \001-n p-\177 ] - - State #8 is non-accepting - - associated rule line numbers: - 3 - out-transitions: [ a ] - jam-transitions: EOF [ \001-` b-\177 ] - - State #9 is non-accepting - - associated rule line numbers: - 3 - out-transitions: [ r ] - jam-transitions: EOF [ \001-q s-\177 ] - - Compressed tables always back up. - - The first few lines tell us that there's a scanner state in - which it can make a transition on an 'o' but not on any - other character, and that in that state the currently - scanned text does not match any rule. The state occurs when - trying to match the rules found at lines 2 and 3 in the - input file. If the scanner is in that state and then reads - something other than an 'o', it will have to back up to find - a rule which is matched. With a bit of headscratching one - can see that this must be the state it's in when it has seen - "fo". When this has happened, if anything other than - another 'o' is seen, the scanner will have to back up to - simply match the 'f' (by the default rule). - - The comment regarding State #8 indicates there's a problem - when "foob" has been scanned. Indeed, on any character - other than an 'a', the scanner will have to back up to - accept "foo". Similarly, the comment for State #9 concerns - when "fooba" has been scanned and an 'r' does not follow. - - The final comment reminds us that there's no point going to - all the trouble of removing backing up from the rules unless - we're using -Cf or -CF, since there's no performance gain - doing so with compressed scanners. - - The way to remove the backing up is to add "error" rules: - - %% - - - -Version 2.5 Last change: April 1995 40 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - foo return TOK_KEYWORD; - foobar return TOK_KEYWORD; - - fooba | - foob | - fo { - /* false alarm, not really a keyword */ - return TOK_ID; - } - - - Eliminating backing up among a list of keywords can also be - done using a "catch-all" rule: - - %% - foo return TOK_KEYWORD; - foobar return TOK_KEYWORD; - - [a-z]+ return TOK_ID; - - This is usually the best solution when appropriate. - - Backing up messages tend to cascade. With a complicated set - of rules it's not uncommon to get hundreds of messages. If - one can decipher them, though, it often only takes a dozen - or so rules to eliminate the backing up (though it's easy to - make a mistake and have an error rule accidentally match a - valid token. A possible future flex feature will be to - automatically add rules to eliminate backing up). - - It's important to keep in mind that you gain the benefits of - eliminating backing up only if you eliminate every instance - of backing up. Leaving just one means you gain nothing. - - Variable trailing context (where both the leading and trail- - ing parts do not have a fixed length) entails almost the - same performance loss as REJECT (i.e., substantial). So - when possible a rule like: - - %% - mouse|rat/(cat|dog) run(); - - is better written: - - %% - mouse/cat|dog run(); - rat/cat|dog run(); - - or as - - %% - mouse|rat/cat run(); - - - -Version 2.5 Last change: April 1995 41 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - mouse|rat/dog run(); - - Note that here the special '|' action does not provide any - savings, and can even make things worse (see Deficiencies / - Bugs below). - - Another area where the user can increase a scanner's perfor- - mance (and one that's easier to implement) arises from the - fact that the longer the tokens matched, the faster the - scanner will run. This is because with long tokens the pro- - cessing of most input characters takes place in the (short) - inner scanning loop, and does not often have to go through - the additional work of setting up the scanning environment - (e.g., yytext) for the action. Recall the scanner for C - comments: - - %x comment - %% - int line_num = 1; - - "/*" BEGIN(comment); - - [^*\n]* - "*"+[^*/\n]* - \n ++line_num; - "*"+"/" BEGIN(INITIAL); - - This could be sped up by writing it as: - - %x comment - %% - int line_num = 1; - - "/*" BEGIN(comment); - - [^*\n]* - [^*\n]*\n ++line_num; - "*"+[^*/\n]* - "*"+[^*/\n]*\n ++line_num; - "*"+"/" BEGIN(INITIAL); - - Now instead of each newline requiring the processing of - another action, recognizing the newlines is "distributed" - over the other rules to keep the matched text as long as - possible. Note that adding rules does not slow down the - scanner! The speed of the scanner is independent of the - number of rules or (modulo the considerations given at the - beginning of this section) how complicated the rules are - with regard to operators such as '*' and '|'. - - A final example in speeding up a scanner: suppose you want - to scan through a file containing identifiers and keywords, - - - -Version 2.5 Last change: April 1995 42 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - one per line and with no other extraneous characters, and - recognize all the keywords. A natural first approach is: - - %% - asm | - auto | - break | - ... etc ... - volatile | - while /* it's a keyword */ - - .|\n /* it's not a keyword */ - - To eliminate the back-tracking, introduce a catch-all rule: - - %% - asm | - auto | - break | - ... etc ... - volatile | - while /* it's a keyword */ - - [a-z]+ | - .|\n /* it's not a keyword */ - - Now, if it's guaranteed that there's exactly one word per - line, then we can reduce the total number of matches by a - half by merging in the recognition of newlines with that of - the other tokens: - - %% - asm\n | - auto\n | - break\n | - ... etc ... - volatile\n | - while\n /* it's a keyword */ - - [a-z]+\n | - .|\n /* it's not a keyword */ - - One has to be careful here, as we have now reintroduced - backing up into the scanner. In particular, while we know - that there will never be any characters in the input stream - other than letters or newlines, flex can't figure this out, - and it will plan for possibly needing to back up when it has - scanned a token like "auto" and then the next character is - something other than a newline or a letter. Previously it - would then just match the "auto" rule and be done, but now - it has no "auto" rule, only a "auto\n" rule. To eliminate - the possibility of backing up, we could either duplicate all - - - -Version 2.5 Last change: April 1995 43 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - rules but without final newlines, or, since we never expect - to encounter such an input and therefore don't how it's - classified, we can introduce one more catch-all rule, this - one which doesn't include a newline: - - %% - asm\n | - auto\n | - break\n | - ... etc ... - volatile\n | - while\n /* it's a keyword */ - - [a-z]+\n | - [a-z]+ | - .|\n /* it's not a keyword */ - - Compiled with -Cf, this is about as fast as one can get a - flex scanner to go for this particular problem. - - A final note: flex is slow when matching NUL's, particularly - when a token contains multiple NUL's. It's best to write - rules which match short amounts of text if it's anticipated - that the text will often include NUL's. - - Another final note regarding performance: as mentioned above - in the section How the Input is Matched, dynamically resiz- - ing yytext to accommodate huge tokens is a slow process - because it presently requires that the (huge) token be res- - canned from the beginning. Thus if performance is vital, - you should attempt to match "large" quantities of text but - not "huge" quantities, where the cutoff between the two is - at about 8K characters/token. - -GENERATING C++ SCANNERS - flex provides two different ways to generate scanners for - use with C++. The first way is to simply compile a scanner - generated by flex using a C++ compiler instead of a C com- - piler. You should not encounter any compilations errors - (please report any you find to the email address given in - the Author section below). You can then use C++ code in - your rule actions instead of C code. Note that the default - input source for your scanner remains yyin, and default - echoing is still done to yyout. Both of these remain FILE * - variables and not C++ streams. - - You can also use flex to generate a C++ scanner class, using - the -+ option (or, equivalently, %option c++), which is - automatically specified if the name of the flex executable - ends in a '+', such as flex++. When using this option, flex - defaults to generating the scanner to the file lex.yy.cc - instead of lex.yy.c. The generated scanner includes the - - - -Version 2.5 Last change: April 1995 44 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - header file FlexLexer.h, which defines the interface to two - C++ classes. - - The first class, FlexLexer, provides an abstract base class - defining the general scanner class interface. It provides - the following member functions: - - const char* YYText() - returns the text of the most recently matched token, - the equivalent of yytext. - - int YYLeng() - returns the length of the most recently matched token, - the equivalent of yyleng. - - int lineno() const - returns the current input line number (see %option - yylineno), or 1 if %option yylineno was not used. - - void set_debug( int flag ) - sets the debugging flag for the scanner, equivalent to - assigning to yy_flex_debug (see the Options section - above). Note that you must build the scanner using - %option debug to include debugging information in it. - - int debug() const - returns the current setting of the debugging flag. - - Also provided are member functions equivalent to - yy_switch_to_buffer(), yy_create_buffer() (though the first - argument is an istream* object pointer and not a FILE*), - yy_flush_buffer(), yy_delete_buffer(), and yyrestart() - (again, the first argument is a istream* object pointer). - - The second class defined in FlexLexer.h is yyFlexLexer, - which is derived from FlexLexer. It defines the following - additional member functions: - - yyFlexLexer( istream* arg_yyin = 0, ostream* arg_yyout = 0 ) - constructs a yyFlexLexer object using the given streams - for input and output. If not specified, the streams - default to cin and cout, respectively. - - virtual int yylex() - performs the same role is yylex() does for ordinary - flex scanners: it scans the input stream, consuming - tokens, until a rule's action returns a value. If you - derive a subclass S from yyFlexLexer and want to access - the member functions and variables of S inside yylex(), - then you need to use %option yyclass="S" to inform flex - that you will be using that subclass instead of yyFlex- - Lexer. In this case, rather than generating - - - -Version 2.5 Last change: April 1995 45 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - yyFlexLexer::yylex(), flex generates S::yylex() (and - also generates a dummy yyFlexLexer::yylex() that calls - yyFlexLexer::LexerError() if called). - - virtual void switch_streams(istream* new_in = 0, - ostream* new_out = 0) reassigns yyin to new_in (if - non-nil) and yyout to new_out (ditto), deleting the - previous input buffer if yyin is reassigned. - - int yylex( istream* new_in, ostream* new_out = 0 ) - first switches the input streams via switch_streams( - new_in, new_out ) and then returns the value of - yylex(). - - In addition, yyFlexLexer defines the following protected - virtual functions which you can redefine in derived classes - to tailor the scanner: - - virtual int LexerInput( char* buf, int max_size ) - reads up to max_size characters into buf and returns - the number of characters read. To indicate end-of- - input, return 0 characters. Note that "interactive" - scanners (see the -B and -I flags) define the macro - YY_INTERACTIVE. If you redefine LexerInput() and need - to take different actions depending on whether or not - the scanner might be scanning an interactive input - source, you can test for the presence of this name via - #ifdef. - - virtual void LexerOutput( const char* buf, int size ) - writes out size characters from the buffer buf, which, - while NUL-terminated, may also contain "internal" NUL's - if the scanner's rules can match text with NUL's in - them. - - virtual void LexerError( const char* msg ) - reports a fatal error message. The default version of - this function writes the message to the stream cerr and - exits. - - Note that a yyFlexLexer object contains its entire scanning - state. Thus you can use such objects to create reentrant - scanners. You can instantiate multiple instances of the - same yyFlexLexer class, and you can also combine multiple - C++ scanner classes together in the same program using the - -P option discussed above. - - Finally, note that the %array feature is not available to - C++ scanner classes; you must use %pointer (the default). - - Here is an example of a simple C++ scanner: - - - - -Version 2.5 Last change: April 1995 46 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - // An example of using the flex C++ scanner class. - - %{ - int mylineno = 0; - %} - - string \"[^\n"]+\" - - ws [ \t]+ - - alpha [A-Za-z] - dig [0-9] - name ({alpha}|{dig}|\$)({alpha}|{dig}|[_.\-/$])* - num1 [-+]?{dig}+\.?([eE][-+]?{dig}+)? - num2 [-+]?{dig}*\.{dig}+([eE][-+]?{dig}+)? - number {num1}|{num2} - - %% - - {ws} /* skip blanks and tabs */ - - "/*" { - int c; - - while((c = yyinput()) != 0) - { - if(c == '\n') - ++mylineno; - - else if(c == '*') - { - if((c = yyinput()) == '/') - break; - else - unput(c); - } - } - } - - {number} cout << "number " << YYText() << '\n'; - - \n mylineno++; - - {name} cout << "name " << YYText() << '\n'; - - {string} cout << "string " << YYText() << '\n'; - - %% - - int main( int /* argc */, char** /* argv */ ) - { - FlexLexer* lexer = new yyFlexLexer; - - - -Version 2.5 Last change: April 1995 47 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - while(lexer->yylex() != 0) - ; - return 0; - } - If you want to create multiple (different) lexer classes, - you use the -P flag (or the prefix= option) to rename each - yyFlexLexer to some other xxFlexLexer. You then can include - in your other sources once per lexer class, - first renaming yyFlexLexer as follows: - - #undef yyFlexLexer - #define yyFlexLexer xxFlexLexer - #include - - #undef yyFlexLexer - #define yyFlexLexer zzFlexLexer - #include - - if, for example, you used %option prefix="xx" for one of - your scanners and %option prefix="zz" for the other. - - IMPORTANT: the present form of the scanning class is experi- - mental and may change considerably between major releases. - -INCOMPATIBILITIES WITH LEX AND POSIX - flex is a rewrite of the AT&T Unix lex tool (the two imple- - mentations do not share any code, though), with some exten- - sions and incompatibilities, both of which are of concern to - those who wish to write scanners acceptable to either imple- - mentation. Flex is fully compliant with the POSIX lex - specification, except that when using %pointer (the - default), a call to unput() destroys the contents of yytext, - which is counter to the POSIX specification. - - In this section we discuss all of the known areas of incom- - patibility between flex, AT&T lex, and the POSIX specifica- - tion. - - flex's -l option turns on maximum compatibility with the - original AT&T lex implementation, at the cost of a major - loss in the generated scanner's performance. We note below - which incompatibilities can be overcome using the -l option. - - flex is fully compatible with lex with the following excep- - tions: - - - The undocumented lex scanner internal variable yylineno - is not supported unless -l or %option yylineno is used. - - yylineno should be maintained on a per-buffer basis, - rather than a per-scanner (single global variable) - basis. - - - -Version 2.5 Last change: April 1995 48 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - yylineno is not part of the POSIX specification. - - - The input() routine is not redefinable, though it may - be called to read characters following whatever has - been matched by a rule. If input() encounters an end- - of-file the normal yywrap() processing is done. A - ``real'' end-of-file is returned by input() as EOF. - - Input is instead controlled by defining the YY_INPUT - macro. - - The flex restriction that input() cannot be redefined - is in accordance with the POSIX specification, which - simply does not specify any way of controlling the - scanner's input other than by making an initial assign- - ment to yyin. - - - The unput() routine is not redefinable. This restric- - tion is in accordance with POSIX. - - - flex scanners are not as reentrant as lex scanners. In - particular, if you have an interactive scanner and an - interrupt handler which long-jumps out of the scanner, - and the scanner is subsequently called again, you may - get the following message: - - fatal flex scanner internal error--end of buffer missed - - To reenter the scanner, first use - - yyrestart( yyin ); - - Note that this call will throw away any buffered input; - usually this isn't a problem with an interactive - scanner. - - Also note that flex C++ scanner classes are reentrant, - so if using C++ is an option for you, you should use - them instead. See "Generating C++ Scanners" above for - details. - - - output() is not supported. Output from the ECHO macro - is done to the file-pointer yyout (default stdout). - - output() is not part of the POSIX specification. - - - lex does not support exclusive start conditions (%x), - though they are in the POSIX specification. - - - When definitions are expanded, flex encloses them in - parentheses. With lex, the following: - - - - -Version 2.5 Last change: April 1995 49 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - NAME [A-Z][A-Z0-9]* - %% - foo{NAME}? printf( "Found it\n" ); - %% - - will not match the string "foo" because when the macro - is expanded the rule is equivalent to "foo[A-Z][A-Z0- - 9]*?" and the precedence is such that the '?' is asso- - ciated with "[A-Z0-9]*". With flex, the rule will be - expanded to "foo([A-Z][A-Z0-9]*)?" and so the string - "foo" will match. - - Note that if the definition begins with ^ or ends with - $ then it is not expanded with parentheses, to allow - these operators to appear in definitions without losing - their special meanings. But the , /, and <> - operators cannot be used in a flex definition. - - Using -l results in the lex behavior of no parentheses - around the definition. - - The POSIX specification is that the definition be - enclosed in parentheses. - - - Some implementations of lex allow a rule's action to - begin on a separate line, if the rule's pattern has - trailing whitespace: - - %% - foo|bar - { foobar_action(); } - - flex does not support this feature. - - - The lex %r (generate a Ratfor scanner) option is not - supported. It is not part of the POSIX specification. - - - After a call to unput(), yytext is undefined until the - next token is matched, unless the scanner was built - using %array. This is not the case with lex or the - POSIX specification. The -l option does away with this - incompatibility. - - - The precedence of the {} (numeric range) operator is - different. lex interprets "abc{1,3}" as "match one, - two, or three occurrences of 'abc'", whereas flex - interprets it as "match 'ab' followed by one, two, or - three occurrences of 'c'". The latter is in agreement - with the POSIX specification. - - - The precedence of the ^ operator is different. lex - interprets "^foo|bar" as "match either 'foo' at the - - - -Version 2.5 Last change: April 1995 50 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - beginning of a line, or 'bar' anywhere", whereas flex - interprets it as "match either 'foo' or 'bar' if they - come at the beginning of a line". The latter is in - agreement with the POSIX specification. - - - The special table-size declarations such as %a sup- - ported by lex are not required by flex scanners; flex - ignores them. - - - The name FLEX_SCANNER is #define'd so scanners may be - written for use with either flex or lex. Scanners also - include YY_FLEX_MAJOR_VERSION and YY_FLEX_MINOR_VERSION - indicating which version of flex generated the scanner - (for example, for the 2.5 release, these defines would - be 2 and 5 respectively). - - The following flex features are not included in lex or the - POSIX specification: - - C++ scanners - %option - start condition scopes - start condition stacks - interactive/non-interactive scanners - yy_scan_string() and friends - yyterminate() - yy_set_interactive() - yy_set_bol() - YY_AT_BOL() - <> - <*> - YY_DECL - YY_START - YY_USER_ACTION - YY_USER_INIT - #line directives - %{}'s around actions - multiple actions on a line - - plus almost all of the flex flags. The last feature in the - list refers to the fact that with flex you can put multiple - actions on the same line, separated with semi-colons, while - with lex, the following - - foo handle_foo(); ++num_foos_seen; - - is (rather surprisingly) truncated to - - foo handle_foo(); - - flex does not truncate the action. Actions that are not - enclosed in braces are simply terminated at the end of the - - - -Version 2.5 Last change: April 1995 51 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - line. - -DIAGNOSTICS - warning, rule cannot be matched indicates that the given - rule cannot be matched because it follows other rules that - will always match the same text as it. For example, in the - following "foo" cannot be matched because it comes after an - identifier "catch-all" rule: - - [a-z]+ got_identifier(); - foo got_foo(); - - Using REJECT in a scanner suppresses this warning. - - warning, -s option given but default rule can be matched - means that it is possible (perhaps only in a particular - start condition) that the default rule (match any single - character) is the only one that will match a particular - input. Since -s was given, presumably this is not intended. - - reject_used_but_not_detected undefined or - yymore_used_but_not_detected undefined - These errors can - occur at compile time. They indicate that the scanner uses - REJECT or yymore() but that flex failed to notice the fact, - meaning that flex scanned the first two sections looking for - occurrences of these actions and failed to find any, but - somehow you snuck some in (via a #include file, for exam- - ple). Use %option reject or %option yymore to indicate to - flex that you really do use these features. - - flex scanner jammed - a scanner compiled with -s has encoun- - tered an input string which wasn't matched by any of its - rules. This error can also occur due to internal problems. - - token too large, exceeds YYLMAX - your scanner uses %array - and one of its rules matched a string longer than the YYLMAX - constant (8K bytes by default). You can increase the value - by #define'ing YYLMAX in the definitions section of your - flex input. - - scanner requires -8 flag to use the character 'x' - Your - scanner specification includes recognizing the 8-bit charac- - ter 'x' and you did not specify the -8 flag, and your - scanner defaulted to 7-bit because you used the -Cf or -CF - table compression options. See the discussion of the -7 - flag for details. - - flex scanner push-back overflow - you used unput() to push - back so much text that the scanner's buffer could not hold - both the pushed-back text and the current token in yytext. - Ideally the scanner should dynamically resize the buffer in - this case, but at present it does not. - - - -Version 2.5 Last change: April 1995 52 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - input buffer overflow, can't enlarge buffer because scanner - uses REJECT - the scanner was working on matching an - extremely large token and needed to expand the input buffer. - This doesn't work with scanners that use REJECT. - - fatal flex scanner internal error--end of buffer missed - - This can occur in an scanner which is reentered after a - long-jump has jumped out (or over) the scanner's activation - frame. Before reentering the scanner, use: - - yyrestart( yyin ); - - or, as noted above, switch to using the C++ scanner class. - - too many start conditions in <> you listed more start condi- - tions in a <> construct than exist (so you must have listed - at least one of them twice). - -FILES - -lfl library with which scanners must be linked. - - lex.yy.c - generated scanner (called lexyy.c on some systems). - - lex.yy.cc - generated C++ scanner class, when using -+. - - - header file defining the C++ scanner base class, Flex- - Lexer, and its derived class, yyFlexLexer. - - flex.skl - skeleton scanner. This file is only used when building - flex, not when flex executes. - - lex.backup - backing-up information for -b flag (called lex.bck on - some systems). - -DEFICIENCIES / BUGS - Some trailing context patterns cannot be properly matched - and generate warning messages ("dangerous trailing con- - text"). These are patterns where the ending of the first - part of the rule matches the beginning of the second part, - such as "zx*/xy*", where the 'x*' matches the 'x' at the - beginning of the trailing context. (Note that the POSIX - draft states that the text matched by such patterns is unde- - fined.) - - For some trailing context rules, parts which are actually - fixed-length are not recognized as such, leading to the - abovementioned performance loss. In particular, parts using - - - -Version 2.5 Last change: April 1995 53 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - '|' or {n} (such as "foo{3}") are always considered - variable-length. - - Combining trailing context with the special '|' action can - result in fixed trailing context being turned into the more - expensive variable trailing context. For example, in the - following: - - %% - abc | - xyz/def - - - Use of unput() invalidates yytext and yyleng, unless the - %array directive or the -l option has been used. - - Pattern-matching of NUL's is substantially slower than - matching other characters. - - Dynamic resizing of the input buffer is slow, as it entails - rescanning all the text matched so far by the current (gen- - erally huge) token. - - Due to both buffering of input and read-ahead, you cannot - intermix calls to routines, such as, for example, - getchar(), with flex rules and expect it to work. Call - input() instead. - - The total table entries listed by the -v flag excludes the - number of table entries needed to determine what rule has - been matched. The number of entries is equal to the number - of DFA states if the scanner does not use REJECT, and some- - what greater than the number of states if it does. - - REJECT cannot be used with the -f or -F options. - - The flex internal algorithms need documentation. - -SEE ALSO - lex(1), yacc(1), sed(1), awk(1). - - John Levine, Tony Mason, and Doug Brown, Lex & Yacc, - O'Reilly and Associates. Be sure to get the 2nd edition. - - M. E. Lesk and E. Schmidt, LEX - Lexical Analyzer Generator - - Alfred Aho, Ravi Sethi and Jeffrey Ullman, Compilers: Prin- - ciples, Techniques and Tools, Addison-Wesley (1986). - Describes the pattern-matching techniques used by flex - (deterministic finite automata). - - - - - -Version 2.5 Last change: April 1995 54 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - -AUTHOR - Vern Paxson, with the help of many ideas and much inspira- - tion from Van Jacobson. Original version by Jef Poskanzer. - The fast table representation is a partial implementation of - a design done by Van Jacobson. The implementation was done - by Kevin Gong and Vern Paxson. - - Thanks to the many flex beta-testers, feedbackers, and con- - tributors, especially Francois Pinard, Casey Leedom, Robert - Abramovitz, Stan Adermann, Terry Allen, David Barker- - Plummer, John Basrai, Neal Becker, Nelson H.F. Beebe, - benson@odi.com, Karl Berry, Peter A. Bigot, Simon Blanchard, - Keith Bostic, Frederic Brehm, Ian Brockbank, Kin Cho, Nick - Christopher, Brian Clapper, J.T. Conklin, Jason Coughlin, - Bill Cox, Nick Cropper, Dave Curtis, Scott David Daniels, - Chris G. Demetriou, Theo Deraadt, Mike Donahue, Chuck - Doucette, Tom Epperly, Leo Eskin, Chris Faylor, Chris - Flatters, Jon Forrest, Jeffrey Friedl, Joe Gayda, Kaveh R. - Ghazi, Wolfgang Glunz, Eric Goldman, Christopher M. Gould, - Ulrich Grepel, Peer Griebel, Jan Hajic, Charles Hemphill, - NORO Hideo, Jarkko Hietaniemi, Scott Hofmann, Jeff Honig, - Dana Hudes, Eric Hughes, John Interrante, Ceriel Jacobs, - Michal Jaegermann, Sakari Jalovaara, Jeffrey R. Jones, Henry - Juengst, Klaus Kaempf, Jonathan I. Kamens, Terrence O Kane, - Amir Katz, ken@ken.hilco.com, Kevin B. Kenny, Steve Kirsch, - Winfried Koenig, Marq Kole, Ronald Lamprecht, Greg Lee, - Rohan Lenard, Craig Leres, John Levine, Steve Liddle, David - Loffredo, Mike Long, Mohamed el Lozy, Brian Madsen, Malte, - Joe Marshall, Bengt Martensson, Chris Metcalf, Luke Mewburn, - Jim Meyering, R. Alexander Milowski, Erik Naggum, G.T. - Nicol, Landon Noll, James Nordby, Marc Nozell, Richard - Ohnemus, Karsten Pahnke, Sven Panne, Roland Pesch, Walter - Pelissero, Gaumond Pierre, Esmond Pitt, Jef Poskanzer, Joe - Rahmeh, Jarmo Raiha, Frederic Raimbault, Pat Rankin, Rick - Richardson, Kevin Rodgers, Kai Uwe Rommel, Jim Roskind, - Alberto Santini, Andreas Scherer, Darrell Schiebel, Raf - Schietekat, Doug Schmidt, Philippe Schnoebelen, Andreas - Schwab, Larry Schwimmer, Alex Siegel, Eckehard Stolz, Jan- - Erik Strvmquist, Mike Stump, Paul Stuart, Dave Tallman, Ian - Lance Taylor, Chris Thewalt, Richard M. Timoney, Jodi Tsai, - Paul Tuinenga, Gary Weik, Frank Whaley, Gerhard Wilhelms, - Kent Williams, Ken Yap, Ron Zellar, Nathan Zelle, David - Zuhn, and those whose names have slipped my marginal mail- - archiving skills but whose contributions are appreciated all - the same. - - Thanks to Keith Bostic, Jon Forrest, Noah Friedman, John - Gilmore, Craig Leres, John Levine, Bob Mulcahy, G.T. Nicol, - Francois Pinard, Rich Salz, and Richard Stallman for help - with various distribution headaches. - - - - - -Version 2.5 Last change: April 1995 55 - - - - - - -FLEX(1) USER COMMANDS FLEX(1) - - - - Thanks to Esmond Pitt and Earle Horton for 8-bit character - support; to Benson Margulies and Fred Burke for C++ support; - to Kent Williams and Tom Epperly for C++ class support; to - Ove Ewerlid for support of NUL's; and to Eric Hughes for - support of multiple buffers. - - This work was primarily done when I was with the Real Time - Systems Group at the Lawrence Berkeley Laboratory in Berke- - ley, CA. Many thanks to all there for the support I - received. - - Send comments to vern@ee.lbl.gov. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Version 2.5 Last change: April 1995 56 - - - diff --git a/commands/flex-2.5.4/MISC/parse.c b/commands/flex-2.5.4/MISC/parse.c deleted file mode 100644 index f5f1d80f5..000000000 --- a/commands/flex-2.5.4/MISC/parse.c +++ /dev/null @@ -1,1452 +0,0 @@ -#ifndef lint -static char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; -#endif -#define YYBYACC 1 -#define YYMAJOR 1 -#define YYMINOR 9 -#define yyclearin (yychar=(-1)) -#define yyerrok (yyerrflag=0) -#define YYRECOVERING (yyerrflag!=0) -#define YYPREFIX "yy" -#line 10 "./parse.y" -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Vern Paxson. - * - * The United States Government has rights in this work pursuant - * to contract no. DE-AC03-76SF00098 between the United States - * Department of Energy and the University of California. - * - * Redistribution and use in source and binary forms with or without - * modification are permitted provided that: (1) source distributions retain - * this entire copyright notice and comment, and (2) distributions including - * binaries display the following acknowledgement: ``This product includes - * software developed by the University of California, Berkeley and its - * contributors'' in the documentation or other materials provided with the - * distribution and in all advertising materials mentioning features or use - * of this software. Neither the name of the University nor the names of - * its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -/* $Header$ */ - - -/* Some versions of bison are broken in that they use alloca() but don't - * declare it properly. The following is the patented (just kidding!) - * #ifdef chud to fix the problem, courtesy of Francois Pinard. - */ -#ifdef YYBISON -/* AIX requires this to be the first thing in the file. What a piece. */ -# ifdef _AIX - #pragma alloca -# endif -#endif - -#include "flexdef.h" - -/* The remainder of the alloca() cruft has to come after including flexdef.h, - * so HAVE_ALLOCA_H is (possibly) defined. - */ -#ifdef YYBISON -# ifdef __GNUC__ -# ifndef alloca -# define alloca __builtin_alloca -# endif -# else -# if HAVE_ALLOCA_H -# include -# else -# ifdef __hpux -void *alloca (); -# else -# ifdef __TURBOC__ -# include -# else -char *alloca (); -# endif -# endif -# endif -# endif -#endif - -/* Bletch, ^^^^ that was ugly! */ - - -int pat, scnum, eps, headcnt, trailcnt, anyccl, lastchar, i, rulelen; -int trlcontxt, xcluflg, currccl, cclsorted, varlength, variable_trail_rule; - -int *scon_stk; -int scon_stk_ptr; - -static int madeany = false; /* whether we've made the '.' character class */ -int previous_continued_action; /* whether the previous rule's action was '|' */ - -/* Expand a POSIX character class expression. */ -#define CCL_EXPR(func) \ - { \ - int c; \ - for ( c = 0; c < csize; ++c ) \ - if ( isascii(c) && func(c) ) \ - ccladd( currccl, c ); \ - } - -/* While POSIX defines isblank(), it's not ANSI C. */ -#define IS_BLANK(c) ((c) == ' ' || (c) == '\t') - -/* On some over-ambitious machines, such as DEC Alpha's, the default - * token type is "long" instead of "int"; this leads to problems with - * declaring yylval in flexdef.h. But so far, all the yacc's I've seen - * wrap their definitions of YYSTYPE with "#ifndef YYSTYPE"'s, so the - * following should ensure that the default token type is "int". - */ -#define YYSTYPE int - -#line 112 "y.tab.c" -#define CHAR 257 -#define NUMBER 258 -#define SECTEND 259 -#define SCDECL 260 -#define XSCDECL 261 -#define NAME 262 -#define PREVCCL 263 -#define EOF_OP 264 -#define OPTION_OP 265 -#define OPT_OUTFILE 266 -#define OPT_PREFIX 267 -#define OPT_YYCLASS 268 -#define CCE_ALNUM 269 -#define CCE_ALPHA 270 -#define CCE_BLANK 271 -#define CCE_CNTRL 272 -#define CCE_DIGIT 273 -#define CCE_GRAPH 274 -#define CCE_LOWER 275 -#define CCE_PRINT 276 -#define CCE_PUNCT 277 -#define CCE_SPACE 278 -#define CCE_UPPER 279 -#define CCE_XDIGIT 280 -#define YYERRCODE 256 -short yylhs[] = { -1, - 0, 1, 2, 2, 2, 2, 3, 6, 6, 7, - 7, 7, 8, 9, 9, 10, 10, 10, 4, 4, - 4, 5, 12, 12, 12, 12, 14, 11, 11, 11, - 15, 15, 15, 16, 13, 13, 13, 13, 18, 18, - 17, 19, 19, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 21, 21, 23, 23, 23, - 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 22, 22, -}; -short yylen[] = { 2, - 5, 0, 3, 2, 0, 1, 1, 1, 1, 2, - 1, 1, 2, 2, 0, 3, 3, 3, 5, 5, - 0, 0, 2, 1, 1, 1, 0, 4, 3, 0, - 3, 1, 1, 1, 2, 3, 2, 1, 3, 1, - 2, 2, 1, 2, 2, 2, 6, 5, 4, 1, - 1, 1, 3, 3, 1, 3, 4, 4, 2, 2, - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 2, 0, -}; -short yydefred[] = { 2, - 0, 0, 6, 0, 7, 8, 9, 15, 21, 0, - 4, 0, 0, 12, 11, 0, 0, 0, 0, 14, - 0, 1, 0, 10, 0, 0, 0, 0, 0, 21, - 0, 16, 17, 18, 29, 33, 34, 0, 32, 0, - 26, 55, 52, 25, 0, 50, 75, 0, 0, 0, - 24, 0, 0, 0, 0, 51, 28, 0, 20, 23, - 0, 0, 61, 0, 19, 0, 37, 0, 41, 0, - 0, 44, 45, 46, 31, 74, 53, 54, 0, 0, - 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, - 72, 73, 56, 60, 36, 0, 0, 57, 0, 49, - 0, 58, 0, 48, 47, -}; -short yydgoto[] = { 1, - 2, 4, 9, 13, 22, 10, 16, 11, 12, 20, - 23, 50, 51, 29, 38, 39, 52, 53, 54, 55, - 56, 61, 64, 94, -}; -short yysindex[] = { 0, - 0, -235, 0, -191, 0, 0, 0, 0, 0, -207, - 0, -215, -18, 0, 0, -202, 4, 26, 32, 0, - 41, 0, -35, 0, -168, -166, -165, 38, -180, 0, - -30, 0, 0, 0, 0, 0, 0, -16, 0, -40, - 0, 0, 0, 0, -2, 0, 0, -2, 8, 93, - 0, -2, -25, -2, 15, 0, 0, -153, 0, 0, - -27, -26, 0, -88, 0, -23, 0, -2, 0, 15, - -150, 0, 0, 0, 0, 0, 0, 0, -3, 65, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, -2, -21, 0, -145, 0, - -116, 0, -12, 0, 0, -}; -short yyrindex[] = { 0, - 0, -188, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -154, 1, 0, 0, -140, 0, 0, 0, 0, - -176, 0, -28, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, -32, - 0, 0, 0, 0, 0, 0, 0, 0, 22, 0, - 0, 0, 106, 7, -10, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 108, 0, 0, 0, -7, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, - 0, 0, 0, 0, 0, -}; -short yygindex[] = { 0, - 0, 0, 0, 92, 100, 0, 0, 0, 0, 0, - 0, 0, 81, 0, 0, 69, 0, 27, 60, -29, - 0, 0, 66, 0, -}; -#define YYTABLESIZE 326 -short yytable[] = { 43, - 22, 30, 42, 47, 93, 22, 77, 30, 104, 48, - 67, 22, 95, 30, 78, 46, 40, 22, 39, 21, - 3, 69, 101, 43, 70, 43, 42, 58, 42, 43, - 43, 47, 42, 42, 30, 43, 43, 48, 42, 42, - 30, 21, 40, 46, 39, 57, 30, 40, 14, 39, - 17, 18, 19, 40, 15, 39, 72, 73, 30, 24, - 49, 30, 22, 45, 25, 22, 70, 5, 6, 7, - 5, 5, 5, 8, 62, 36, 5, 74, 66, 27, - 43, 37, 28, 42, 59, 27, 26, 30, 49, 98, - 30, 30, 27, 32, 30, 33, 34, 68, 68, 35, - 68, 63, 65, 100, 13, 13, 13, 97, 37, 99, - 13, 102, 105, 43, 61, 38, 42, 35, 3, 3, - 3, 40, 31, 30, 3, 60, 75, 96, 79, 0, - 40, 0, 39, 0, 0, 0, 0, 71, 59, 0, - 0, 103, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 80, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, - 91, 92, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 30, 30, 41, 42, 22, 22, 76, - 30, 30, 43, 44, 22, 22, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 43, 0, 0, 42, - 0, 0, 43, 80, 42, 42, 30, 30, 0, 0, - 43, 0, 0, 30, 30, 81, 82, 83, 84, 85, - 86, 87, 88, 89, 90, 91, 92, 0, 61, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 59, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 59, 59, 59, 59, 59, 59, - 59, 59, 59, 59, 59, 59, -}; -short yycheck[] = { 10, - 0, 34, 10, 34, 93, 34, 34, 40, 125, 40, - 36, 40, 36, 46, 41, 46, 10, 46, 10, 60, - 256, 47, 44, 34, 54, 36, 34, 44, 36, 40, - 41, 34, 40, 41, 34, 46, 47, 40, 46, 47, - 40, 60, 36, 46, 36, 62, 46, 41, 256, 41, - 266, 267, 268, 47, 262, 47, 42, 43, 91, 262, - 91, 94, 91, 94, 61, 94, 96, 259, 260, 261, - 259, 260, 261, 265, 48, 256, 265, 63, 52, 256, - 91, 262, 42, 91, 125, 262, 61, 123, 91, 93, - 123, 91, 61, 262, 94, 262, 262, 124, 124, 62, - 124, 94, 10, 125, 259, 260, 261, 258, 262, 45, - 265, 257, 125, 124, 93, 10, 124, 10, 259, 260, - 261, 30, 23, 123, 265, 45, 58, 68, 63, -1, - 124, -1, 124, -1, -1, -1, -1, 123, 93, -1, - -1, 258, -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, 257, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, - 279, 280, -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, 256, 257, 256, 257, 256, 257, 257, - 263, 264, 263, 264, 263, 264, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 257, -1, -1, 257, - -1, -1, 263, 257, 257, 263, 256, 257, -1, -1, - 263, -1, -1, 263, 264, 269, 270, 271, 272, 273, - 274, 275, 276, 277, 278, 279, 280, -1, 257, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, - 279, 280, 257, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 269, 270, 271, 272, 273, 274, - 275, 276, 277, 278, 279, 280, -}; -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 280 -#if YYDEBUG -char *yyname[] = { -"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,"'\"'",0,"'$'",0,0,0,"'('","')'","'*'","'+'","','","'-'","'.'","'/'",0,0, -0,0,0,0,0,0,0,0,0,0,"'<'","'='","'>'","'?'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,"'['",0,"']'","'^'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,"'{'","'|'","'}'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"CHAR","NUMBER","SECTEND", -"SCDECL","XSCDECL","NAME","PREVCCL","EOF_OP","OPTION_OP","OPT_OUTFILE", -"OPT_PREFIX","OPT_YYCLASS","CCE_ALNUM","CCE_ALPHA","CCE_BLANK","CCE_CNTRL", -"CCE_DIGIT","CCE_GRAPH","CCE_LOWER","CCE_PRINT","CCE_PUNCT","CCE_SPACE", -"CCE_UPPER","CCE_XDIGIT", -}; -char *yyrule[] = { -"$accept : goal", -"goal : initlex sect1 sect1end sect2 initforrule", -"initlex :", -"sect1 : sect1 startconddecl namelist1", -"sect1 : sect1 options", -"sect1 :", -"sect1 : error", -"sect1end : SECTEND", -"startconddecl : SCDECL", -"startconddecl : XSCDECL", -"namelist1 : namelist1 NAME", -"namelist1 : NAME", -"namelist1 : error", -"options : OPTION_OP optionlist", -"optionlist : optionlist option", -"optionlist :", -"option : OPT_OUTFILE '=' NAME", -"option : OPT_PREFIX '=' NAME", -"option : OPT_YYCLASS '=' NAME", -"sect2 : sect2 scon initforrule flexrule '\\n'", -"sect2 : sect2 scon '{' sect2 '}'", -"sect2 :", -"initforrule :", -"flexrule : '^' rule", -"flexrule : rule", -"flexrule : EOF_OP", -"flexrule : error", -"scon_stk_ptr :", -"scon : '<' scon_stk_ptr namelist2 '>'", -"scon : '<' '*' '>'", -"scon :", -"namelist2 : namelist2 ',' sconname", -"namelist2 : sconname", -"namelist2 : error", -"sconname : NAME", -"rule : re2 re", -"rule : re2 re '$'", -"rule : re '$'", -"rule : re", -"re : re '|' series", -"re : series", -"re2 : re '/'", -"series : series singleton", -"series : singleton", -"singleton : singleton '*'", -"singleton : singleton '+'", -"singleton : singleton '?'", -"singleton : singleton '{' NUMBER ',' NUMBER '}'", -"singleton : singleton '{' NUMBER ',' '}'", -"singleton : singleton '{' NUMBER '}'", -"singleton : '.'", -"singleton : fullccl", -"singleton : PREVCCL", -"singleton : '\"' string '\"'", -"singleton : '(' re ')'", -"singleton : CHAR", -"fullccl : '[' ccl ']'", -"fullccl : '[' '^' ccl ']'", -"ccl : ccl CHAR '-' CHAR", -"ccl : ccl CHAR", -"ccl : ccl ccl_expr", -"ccl :", -"ccl_expr : CCE_ALNUM", -"ccl_expr : CCE_ALPHA", -"ccl_expr : CCE_BLANK", -"ccl_expr : CCE_CNTRL", -"ccl_expr : CCE_DIGIT", -"ccl_expr : CCE_GRAPH", -"ccl_expr : CCE_LOWER", -"ccl_expr : CCE_PRINT", -"ccl_expr : CCE_PUNCT", -"ccl_expr : CCE_SPACE", -"ccl_expr : CCE_UPPER", -"ccl_expr : CCE_XDIGIT", -"string : string CHAR", -"string :", -}; -#endif -#ifndef YYSTYPE -typedef int YYSTYPE; -#endif -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 500 -#define YYMAXDEPTH 500 -#endif -#endif -int yydebug; -int yynerrs; -int yyerrflag; -int yychar; -short *yyssp; -YYSTYPE *yyvsp; -YYSTYPE yyval; -YYSTYPE yylval; -short yyss[YYSTACKSIZE]; -YYSTYPE yyvs[YYSTACKSIZE]; -#define yystacksize YYSTACKSIZE -#line 776 "./parse.y" - - -/* build_eof_action - build the "<>" action for the active start - * conditions - */ - -void build_eof_action() - { - register int i; - char action_text[MAXLINE]; - - for ( i = 1; i <= scon_stk_ptr; ++i ) - { - if ( sceof[scon_stk[i]] ) - format_pinpoint_message( - "multiple <> rules for start condition %s", - scname[scon_stk[i]] ); - - else - { - sceof[scon_stk[i]] = true; - sprintf( action_text, "case YY_STATE_EOF(%s):\n", - scname[scon_stk[i]] ); - add_action( action_text ); - } - } - - line_directive_out( (FILE *) 0, 1 ); - - /* This isn't a normal rule after all - don't count it as - * such, so we don't have any holes in the rule numbering - * (which make generating "rule can never match" warnings - * more difficult. - */ - --num_rules; - ++num_eof_rules; - } - - -/* format_synerr - write out formatted syntax error */ - -void format_synerr( msg, arg ) -char msg[], arg[]; - { - char errmsg[MAXLINE]; - - (void) sprintf( errmsg, msg, arg ); - synerr( errmsg ); - } - - -/* synerr - report a syntax error */ - -void synerr( str ) -char str[]; - { - syntaxerror = true; - pinpoint_message( str ); - } - - -/* format_warn - write out formatted warning */ - -void format_warn( msg, arg ) -char msg[], arg[]; - { - char warn_msg[MAXLINE]; - - (void) sprintf( warn_msg, msg, arg ); - warn( warn_msg ); - } - - -/* warn - report a warning, unless -w was given */ - -void warn( str ) -char str[]; - { - line_warning( str, linenum ); - } - -/* format_pinpoint_message - write out a message formatted with one string, - * pinpointing its location - */ - -void format_pinpoint_message( msg, arg ) -char msg[], arg[]; - { - char errmsg[MAXLINE]; - - (void) sprintf( errmsg, msg, arg ); - pinpoint_message( errmsg ); - } - - -/* pinpoint_message - write out a message, pinpointing its location */ - -void pinpoint_message( str ) -char str[]; - { - line_pinpoint( str, linenum ); - } - - -/* line_warning - report a warning at a given line, unless -w was given */ - -void line_warning( str, line ) -char str[]; -int line; - { - char warning[MAXLINE]; - - if ( ! nowarn ) - { - sprintf( warning, "warning, %s", str ); - line_pinpoint( warning, line ); - } - } - - -/* line_pinpoint - write out a message, pinpointing it at the given line */ - -void line_pinpoint( str, line ) -char str[]; -int line; - { - fprintf( stderr, "\"%s\", line %d: %s\n", infilename, line, str ); - } - - -/* yyerror - eat up an error message from the parser; - * currently, messages are ignore - */ - -void yyerror( msg ) -char msg[]; - { - } -#line 541 "y.tab.c" -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -int -yyparse() -{ - register int yym, yyn, yystate; -#if YYDEBUG - register char *yys; - extern char *getenv(); - - if (yys = getenv("YYDEBUG")) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } -#endif - - yynerrs = 0; - yyerrflag = 0; - yychar = (-1); - - yyssp = yyss; - yyvsp = yyvs; - *yyssp = yystate = 0; - -yyloop: - if (yyn = yydefred[yystate]) goto yyreduce; - if (yychar < 0) - { - if ((yychar = yylex()) < 0) yychar = 0; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yyssp >= yyss + yystacksize - 1) - { - goto yyoverflow; - } - *++yyssp = yystate = yytable[yyn]; - *++yyvsp = yylval; - yychar = (-1); - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag) goto yyinrecovery; -#ifdef lint - goto yynewerror; -#endif -yynewerror: - yyerror("syntax error"); -#ifdef lint - goto yyerrlab; -#endif -yyerrlab: - ++yynerrs; -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yyssp, yytable[yyn]); -#endif - if (yyssp >= yyss + yystacksize - 1) - { - goto yyoverflow; - } - *++yyssp = yystate = yytable[yyn]; - *++yyvsp = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yyssp); -#endif - if (yyssp <= yyss) goto yyabort; - --yyssp; - --yyvsp; - } - } - } - else - { - if (yychar == 0) goto yyabort; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = (-1); - goto yyloop; - } -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - yyval = yyvsp[1-yym]; - switch (yyn) - { -case 1: -#line 113 "./parse.y" -{ /* add default rule */ - int def_rule; - - pat = cclinit(); - cclnegate( pat ); - - def_rule = mkstate( -pat ); - - /* Remember the number of the default rule so we - * don't generate "can't match" warnings for it. - */ - default_rule = num_rules; - - finish_rule( def_rule, false, 0, 0 ); - - for ( i = 1; i <= lastsc; ++i ) - scset[i] = mkbranch( scset[i], def_rule ); - - if ( spprdflt ) - add_action( - "YY_FATAL_ERROR( \"flex scanner jammed\" )" ); - else - add_action( "ECHO" ); - - add_action( ";\n\tYY_BREAK\n" ); - } -break; -case 2: -#line 142 "./parse.y" -{ /* initialize for processing rules */ - - /* Create default DFA start condition. */ - scinstal( "INITIAL", false ); - } -break; -case 6: -#line 153 "./parse.y" -{ synerr( "unknown error processing section 1" ); } -break; -case 7: -#line 157 "./parse.y" -{ - check_options(); - scon_stk = allocate_integer_array( lastsc + 1 ); - scon_stk_ptr = 0; - } -break; -case 8: -#line 165 "./parse.y" -{ xcluflg = false; } -break; -case 9: -#line 168 "./parse.y" -{ xcluflg = true; } -break; -case 10: -#line 172 "./parse.y" -{ scinstal( nmstr, xcluflg ); } -break; -case 11: -#line 175 "./parse.y" -{ scinstal( nmstr, xcluflg ); } -break; -case 12: -#line 178 "./parse.y" -{ synerr( "bad start condition list" ); } -break; -case 16: -#line 189 "./parse.y" -{ - outfilename = copy_string( nmstr ); - did_outfilename = 1; - } -break; -case 17: -#line 194 "./parse.y" -{ prefix = copy_string( nmstr ); } -break; -case 18: -#line 196 "./parse.y" -{ yyclass = copy_string( nmstr ); } -break; -case 19: -#line 200 "./parse.y" -{ scon_stk_ptr = yyvsp[-3]; } -break; -case 20: -#line 202 "./parse.y" -{ scon_stk_ptr = yyvsp[-3]; } -break; -case 22: -#line 207 "./parse.y" -{ - /* Initialize for a parse of one rule. */ - trlcontxt = variable_trail_rule = varlength = false; - trailcnt = headcnt = rulelen = 0; - current_state_type = STATE_NORMAL; - previous_continued_action = continued_action; - in_rule = true; - - new_rule(); - } -break; -case 23: -#line 220 "./parse.y" -{ - pat = yyvsp[0]; - finish_rule( pat, variable_trail_rule, - headcnt, trailcnt ); - - if ( scon_stk_ptr > 0 ) - { - for ( i = 1; i <= scon_stk_ptr; ++i ) - scbol[scon_stk[i]] = - mkbranch( scbol[scon_stk[i]], - pat ); - } - - else - { - /* Add to all non-exclusive start conditions, - * including the default (0) start condition. - */ - - for ( i = 1; i <= lastsc; ++i ) - if ( ! scxclu[i] ) - scbol[i] = mkbranch( scbol[i], - pat ); - } - - if ( ! bol_needed ) - { - bol_needed = true; - - if ( performance_report > 1 ) - pinpoint_message( - "'^' operator results in sub-optimal performance" ); - } - } -break; -case 24: -#line 256 "./parse.y" -{ - pat = yyvsp[0]; - finish_rule( pat, variable_trail_rule, - headcnt, trailcnt ); - - if ( scon_stk_ptr > 0 ) - { - for ( i = 1; i <= scon_stk_ptr; ++i ) - scset[scon_stk[i]] = - mkbranch( scset[scon_stk[i]], - pat ); - } - - else - { - for ( i = 1; i <= lastsc; ++i ) - if ( ! scxclu[i] ) - scset[i] = - mkbranch( scset[i], - pat ); - } - } -break; -case 25: -#line 280 "./parse.y" -{ - if ( scon_stk_ptr > 0 ) - build_eof_action(); - - else - { - /* This EOF applies to all start conditions - * which don't already have EOF actions. - */ - for ( i = 1; i <= lastsc; ++i ) - if ( ! sceof[i] ) - scon_stk[++scon_stk_ptr] = i; - - if ( scon_stk_ptr == 0 ) - warn( - "all start conditions already have <> rules" ); - - else - build_eof_action(); - } - } -break; -case 26: -#line 303 "./parse.y" -{ synerr( "unrecognized rule" ); } -break; -case 27: -#line 307 "./parse.y" -{ yyval = scon_stk_ptr; } -break; -case 28: -#line 311 "./parse.y" -{ yyval = yyvsp[-2]; } -break; -case 29: -#line 314 "./parse.y" -{ - yyval = scon_stk_ptr; - - for ( i = 1; i <= lastsc; ++i ) - { - int j; - - for ( j = 1; j <= scon_stk_ptr; ++j ) - if ( scon_stk[j] == i ) - break; - - if ( j > scon_stk_ptr ) - scon_stk[++scon_stk_ptr] = i; - } - } -break; -case 30: -#line 331 "./parse.y" -{ yyval = scon_stk_ptr; } -break; -case 33: -#line 339 "./parse.y" -{ synerr( "bad start condition list" ); } -break; -case 34: -#line 343 "./parse.y" -{ - if ( (scnum = sclookup( nmstr )) == 0 ) - format_pinpoint_message( - "undeclared start condition %s", - nmstr ); - else - { - for ( i = 1; i <= scon_stk_ptr; ++i ) - if ( scon_stk[i] == scnum ) - { - format_warn( - "<%s> specified twice", - scname[scnum] ); - break; - } - - if ( i > scon_stk_ptr ) - scon_stk[++scon_stk_ptr] = scnum; - } - } -break; -case 35: -#line 366 "./parse.y" -{ - if ( transchar[lastst[yyvsp[0]]] != SYM_EPSILON ) - /* Provide final transition \now/ so it - * will be marked as a trailing context - * state. - */ - yyvsp[0] = link_machines( yyvsp[0], - mkstate( SYM_EPSILON ) ); - - mark_beginning_as_normal( yyvsp[0] ); - current_state_type = STATE_NORMAL; - - if ( previous_continued_action ) - { - /* We need to treat this as variable trailing - * context so that the backup does not happen - * in the action but before the action switch - * statement. If the backup happens in the - * action, then the rules "falling into" this - * one's action will *also* do the backup, - * erroneously. - */ - if ( ! varlength || headcnt != 0 ) - warn( - "trailing context made variable due to preceding '|' action" ); - - /* Mark as variable. */ - varlength = true; - headcnt = 0; - } - - if ( lex_compat || (varlength && headcnt == 0) ) - { /* variable trailing context rule */ - /* Mark the first part of the rule as the - * accepting "head" part of a trailing - * context rule. - * - * By the way, we didn't do this at the - * beginning of this production because back - * then current_state_type was set up for a - * trail rule, and add_accept() can create - * a new state ... - */ - add_accept( yyvsp[-1], - num_rules | YY_TRAILING_HEAD_MASK ); - variable_trail_rule = true; - } - - else - trailcnt = rulelen; - - yyval = link_machines( yyvsp[-1], yyvsp[0] ); - } -break; -case 36: -#line 421 "./parse.y" -{ synerr( "trailing context used twice" ); } -break; -case 37: -#line 424 "./parse.y" -{ - headcnt = 0; - trailcnt = 1; - rulelen = 1; - varlength = false; - - current_state_type = STATE_TRAILING_CONTEXT; - - if ( trlcontxt ) - { - synerr( "trailing context used twice" ); - yyval = mkstate( SYM_EPSILON ); - } - - else if ( previous_continued_action ) - { - /* See the comment in the rule for "re2 re" - * above. - */ - warn( - "trailing context made variable due to preceding '|' action" ); - - varlength = true; - } - - if ( lex_compat || varlength ) - { - /* Again, see the comment in the rule for - * "re2 re" above. - */ - add_accept( yyvsp[-1], - num_rules | YY_TRAILING_HEAD_MASK ); - variable_trail_rule = true; - } - - trlcontxt = true; - - eps = mkstate( SYM_EPSILON ); - yyval = link_machines( yyvsp[-1], - link_machines( eps, mkstate( '\n' ) ) ); - } -break; -case 38: -#line 467 "./parse.y" -{ - yyval = yyvsp[0]; - - if ( trlcontxt ) - { - if ( lex_compat || (varlength && headcnt == 0) ) - /* Both head and trail are - * variable-length. - */ - variable_trail_rule = true; - else - trailcnt = rulelen; - } - } -break; -case 39: -#line 485 "./parse.y" -{ - varlength = true; - yyval = mkor( yyvsp[-2], yyvsp[0] ); - } -break; -case 40: -#line 491 "./parse.y" -{ yyval = yyvsp[0]; } -break; -case 41: -#line 496 "./parse.y" -{ - /* This rule is written separately so the - * reduction will occur before the trailing - * series is parsed. - */ - - if ( trlcontxt ) - synerr( "trailing context used twice" ); - else - trlcontxt = true; - - if ( varlength ) - /* We hope the trailing context is - * fixed-length. - */ - varlength = false; - else - headcnt = rulelen; - - rulelen = 0; - - current_state_type = STATE_TRAILING_CONTEXT; - yyval = yyvsp[-1]; - } -break; -case 42: -#line 523 "./parse.y" -{ - /* This is where concatenation of adjacent patterns - * gets done. - */ - yyval = link_machines( yyvsp[-1], yyvsp[0] ); - } -break; -case 43: -#line 531 "./parse.y" -{ yyval = yyvsp[0]; } -break; -case 44: -#line 535 "./parse.y" -{ - varlength = true; - - yyval = mkclos( yyvsp[-1] ); - } -break; -case 45: -#line 542 "./parse.y" -{ - varlength = true; - yyval = mkposcl( yyvsp[-1] ); - } -break; -case 46: -#line 548 "./parse.y" -{ - varlength = true; - yyval = mkopt( yyvsp[-1] ); - } -break; -case 47: -#line 554 "./parse.y" -{ - varlength = true; - - if ( yyvsp[-3] > yyvsp[-1] || yyvsp[-3] < 0 ) - { - synerr( "bad iteration values" ); - yyval = yyvsp[-5]; - } - else - { - if ( yyvsp[-3] == 0 ) - { - if ( yyvsp[-1] <= 0 ) - { - synerr( - "bad iteration values" ); - yyval = yyvsp[-5]; - } - else - yyval = mkopt( - mkrep( yyvsp[-5], 1, yyvsp[-1] ) ); - } - else - yyval = mkrep( yyvsp[-5], yyvsp[-3], yyvsp[-1] ); - } - } -break; -case 48: -#line 582 "./parse.y" -{ - varlength = true; - - if ( yyvsp[-2] <= 0 ) - { - synerr( "iteration value must be positive" ); - yyval = yyvsp[-4]; - } - - else - yyval = mkrep( yyvsp[-4], yyvsp[-2], INFINITY ); - } -break; -case 49: -#line 596 "./parse.y" -{ - /* The singleton could be something like "(foo)", - * in which case we have no idea what its length - * is, so we punt here. - */ - varlength = true; - - if ( yyvsp[-1] <= 0 ) - { - synerr( "iteration value must be positive" ); - yyval = yyvsp[-3]; - } - - else - yyval = link_machines( yyvsp[-3], - copysingl( yyvsp[-3], yyvsp[-1] - 1 ) ); - } -break; -case 50: -#line 615 "./parse.y" -{ - if ( ! madeany ) - { - /* Create the '.' character class. */ - anyccl = cclinit(); - ccladd( anyccl, '\n' ); - cclnegate( anyccl ); - - if ( useecs ) - mkeccl( ccltbl + cclmap[anyccl], - ccllen[anyccl], nextecm, - ecgroup, csize, csize ); - - madeany = true; - } - - ++rulelen; - - yyval = mkstate( -anyccl ); - } -break; -case 51: -#line 637 "./parse.y" -{ - if ( ! cclsorted ) - /* Sort characters for fast searching. We - * use a shell sort since this list could - * be large. - */ - cshell( ccltbl + cclmap[yyvsp[0]], ccllen[yyvsp[0]], true ); - - if ( useecs ) - mkeccl( ccltbl + cclmap[yyvsp[0]], ccllen[yyvsp[0]], - nextecm, ecgroup, csize, csize ); - - ++rulelen; - - yyval = mkstate( -yyvsp[0] ); - } -break; -case 52: -#line 655 "./parse.y" -{ - ++rulelen; - - yyval = mkstate( -yyvsp[0] ); - } -break; -case 53: -#line 662 "./parse.y" -{ yyval = yyvsp[-1]; } -break; -case 54: -#line 665 "./parse.y" -{ yyval = yyvsp[-1]; } -break; -case 55: -#line 668 "./parse.y" -{ - ++rulelen; - - if ( caseins && yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' ) - yyvsp[0] = clower( yyvsp[0] ); - - yyval = mkstate( yyvsp[0] ); - } -break; -case 56: -#line 679 "./parse.y" -{ yyval = yyvsp[-1]; } -break; -case 57: -#line 682 "./parse.y" -{ - cclnegate( yyvsp[-1] ); - yyval = yyvsp[-1]; - } -break; -case 58: -#line 689 "./parse.y" -{ - if ( caseins ) - { - if ( yyvsp[-2] >= 'A' && yyvsp[-2] <= 'Z' ) - yyvsp[-2] = clower( yyvsp[-2] ); - if ( yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' ) - yyvsp[0] = clower( yyvsp[0] ); - } - - if ( yyvsp[-2] > yyvsp[0] ) - synerr( "negative range in character class" ); - - else - { - for ( i = yyvsp[-2]; i <= yyvsp[0]; ++i ) - ccladd( yyvsp[-3], i ); - - /* Keep track if this ccl is staying in - * alphabetical order. - */ - cclsorted = cclsorted && (yyvsp[-2] > lastchar); - lastchar = yyvsp[0]; - } - - yyval = yyvsp[-3]; - } -break; -case 59: -#line 717 "./parse.y" -{ - if ( caseins && yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' ) - yyvsp[0] = clower( yyvsp[0] ); - - ccladd( yyvsp[-1], yyvsp[0] ); - cclsorted = cclsorted && (yyvsp[0] > lastchar); - lastchar = yyvsp[0]; - yyval = yyvsp[-1]; - } -break; -case 60: -#line 728 "./parse.y" -{ - /* Too hard to properly maintain cclsorted. */ - cclsorted = false; - yyval = yyvsp[-1]; - } -break; -case 61: -#line 735 "./parse.y" -{ - cclsorted = true; - lastchar = 0; - currccl = yyval = cclinit(); - } -break; -case 62: -#line 742 "./parse.y" -{ CCL_EXPR(isalnum) } -break; -case 63: -#line 743 "./parse.y" -{ CCL_EXPR(isalpha) } -break; -case 64: -#line 744 "./parse.y" -{ CCL_EXPR(IS_BLANK) } -break; -case 65: -#line 745 "./parse.y" -{ CCL_EXPR(iscntrl) } -break; -case 66: -#line 746 "./parse.y" -{ CCL_EXPR(isdigit) } -break; -case 67: -#line 747 "./parse.y" -{ CCL_EXPR(isgraph) } -break; -case 68: -#line 748 "./parse.y" -{ CCL_EXPR(islower) } -break; -case 69: -#line 749 "./parse.y" -{ CCL_EXPR(isprint) } -break; -case 70: -#line 750 "./parse.y" -{ CCL_EXPR(ispunct) } -break; -case 71: -#line 751 "./parse.y" -{ CCL_EXPR(isspace) } -break; -case 72: -#line 752 "./parse.y" -{ - if ( caseins ) - CCL_EXPR(islower) - else - CCL_EXPR(isupper) - } -break; -case 73: -#line 758 "./parse.y" -{ CCL_EXPR(isxdigit) } -break; -case 74: -#line 762 "./parse.y" -{ - if ( caseins && yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' ) - yyvsp[0] = clower( yyvsp[0] ); - - ++rulelen; - - yyval = link_machines( yyvsp[-1], mkstate( yyvsp[0] ) ); - } -break; -case 75: -#line 772 "./parse.y" -{ yyval = mkstate( SYM_EPSILON ); } -break; -#line 1397 "y.tab.c" - } - yyssp -= yym; - yystate = *yyssp; - yyvsp -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yyssp = YYFINAL; - *++yyvsp = yyval; - if (yychar < 0) - { - if ((yychar = yylex()) < 0) yychar = 0; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == 0) goto yyaccept; - goto yyloop; - } - if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yyssp, yystate); -#endif - if (yyssp >= yyss + yystacksize - 1) - { - goto yyoverflow; - } - *++yyssp = yystate; - *++yyvsp = yyval; - goto yyloop; -yyoverflow: - yyerror("yacc stack overflow"); -yyabort: - return (1); -yyaccept: - return (0); -} diff --git a/commands/flex-2.5.4/MISC/parse.h b/commands/flex-2.5.4/MISC/parse.h deleted file mode 100644 index 10febed9d..000000000 --- a/commands/flex-2.5.4/MISC/parse.h +++ /dev/null @@ -1,24 +0,0 @@ -#define CHAR 257 -#define NUMBER 258 -#define SECTEND 259 -#define SCDECL 260 -#define XSCDECL 261 -#define NAME 262 -#define PREVCCL 263 -#define EOF_OP 264 -#define OPTION_OP 265 -#define OPT_OUTFILE 266 -#define OPT_PREFIX 267 -#define OPT_YYCLASS 268 -#define CCE_ALNUM 269 -#define CCE_ALPHA 270 -#define CCE_BLANK 271 -#define CCE_CNTRL 272 -#define CCE_DIGIT 273 -#define CCE_GRAPH 274 -#define CCE_LOWER 275 -#define CCE_PRINT 276 -#define CCE_PUNCT 277 -#define CCE_SPACE 278 -#define CCE_UPPER 279 -#define CCE_XDIGIT 280 diff --git a/commands/flex-2.5.4/MISC/testxxLexer.l b/commands/flex-2.5.4/MISC/testxxLexer.l deleted file mode 100644 index 94215411d..000000000 --- a/commands/flex-2.5.4/MISC/testxxLexer.l +++ /dev/null @@ -1,58 +0,0 @@ - // An example of using the flex C++ scanner class. - -%option C++ noyywrap - -%{ -int mylineno = 0; -%} - -string \"[^\n"]+\" - -ws [ \t]+ - -alpha [A-Za-z] -dig [0-9] -name ({alpha}|{dig}|\$)({alpha}|{dig}|\_|\.|\-|\/|\$)* -num1 [-+]?{dig}+\.?([eE][-+]?{dig}+)? -num2 [-+]?{dig}*\.{dig}+([eE][-+]?{dig}+)? -number {num1}|{num2} - -%% - -{ws} /* skip blanks and tabs */ - -"/*" { - int c; - - while((c = yyinput()) != 0) - { - if(c == '\n') - ++mylineno; - - else if(c == '*') - { - if((c = yyinput()) == '/') - break; - else - unput(c); - } - } - } - -{number} cout << "number " << YYText() << '\n'; - -\n mylineno++; - -{name} cout << "name " << YYText() << '\n'; - -{string} cout << "string " << YYText() << '\n'; - -%% - -int main( int /* argc */, char** /* argv */ ) - { - FlexLexer* lexer = new yyFlexLexer; - while(lexer->yylex() != 0) - ; - return 0; - } diff --git a/commands/flex-2.5.4/MISC/texinfo/flex.info b/commands/flex-2.5.4/MISC/texinfo/flex.info deleted file mode 100644 index 926941857..000000000 --- a/commands/flex-2.5.4/MISC/texinfo/flex.info +++ /dev/null @@ -1,2951 +0,0 @@ -This is Info file flex.info, produced by Makeinfo-1.55 from the input -file flex.texi. - -START-INFO-DIR-ENTRY -* Flex: (flex). A fast scanner generator. -END-INFO-DIR-ENTRY - - This file documents Flex. - - Copyright (c) 1990 The Regents of the University of California. All -rights reserved. - - This code is derived from software contributed to Berkeley by Vern -Paxson. - - The United States Government has rights in this work pursuant to -contract no. DE-AC03-76SF00098 between the United States Department of -Energy and the University of California. - - Redistribution and use in source and binary forms with or without -modification are permitted provided that: (1) source distributions -retain this entire copyright notice and comment, and (2) distributions -including binaries display the following acknowledgement: "This -product includes software developed by the University of California, -Berkeley and its contributors" in the documentation or other materials -provided with the distribution and in all advertising materials -mentioning features or use of this software. Neither the name of the -University nor the names of its contributors may be used to endorse or -promote products derived from this software without specific prior -written permission. - - THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - - -File: flex.info, Node: Top, Next: Name, Prev: (dir), Up: (dir) - -flex -**** - - This manual documents `flex'. It covers release 2.5. - -* Menu: - -* Name:: Name -* Synopsis:: Synopsis -* Overview:: Overview -* Description:: Description -* Examples:: Some simple examples -* Format:: Format of the input file -* Patterns:: Patterns -* Matching:: How the input is matched -* Actions:: Actions -* Generated scanner:: The generated scanner -* Start conditions:: Start conditions -* Multiple buffers:: Multiple input buffers -* End-of-file rules:: End-of-file rules -* Miscellaneous:: Miscellaneous macros -* User variables:: Values available to the user -* YACC interface:: Interfacing with `yacc' -* Options:: Options -* Performance:: Performance considerations -* C++:: Generating C++ scanners -* Incompatibilities:: Incompatibilities with `lex' and POSIX -* Diagnostics:: Diagnostics -* Files:: Files -* Deficiencies:: Deficiencies / Bugs -* See also:: See also -* Author:: Author - - -File: flex.info, Node: Name, Next: Synopsis, Prev: Top, Up: Top - -Name -==== - - flex - fast lexical analyzer generator - - -File: flex.info, Node: Synopsis, Next: Overview, Prev: Name, Up: Top - -Synopsis -======== - - flex [-bcdfhilnpstvwBFILTV78+? -C[aefFmr] -ooutput -Pprefix -Sskeleton] - [--help --version] [FILENAME ...] - - -File: flex.info, Node: Overview, Next: Description, Prev: Synopsis, Up: Top - -Overview -======== - - This manual describes `flex', a tool for generating programs that -perform pattern-matching on text. The manual includes both tutorial -and reference sections: - -Description - a brief overview of the tool - -Some Simple Examples -Format Of The Input File -Patterns - the extended regular expressions used by flex - -How The Input Is Matched - the rules for determining what has been matched - -Actions - how to specify what to do when a pattern is matched - -The Generated Scanner - details regarding the scanner that flex produces; how to control - the input source - -Start Conditions - introducing context into your scanners, and managing - "mini-scanners" - -Multiple Input Buffers - how to manipulate multiple input sources; how to scan from strings - instead of files - -End-of-file Rules - special rules for matching the end of the input - -Miscellaneous Macros - a summary of macros available to the actions - -Values Available To The User - a summary of values available to the actions - -Interfacing With Yacc - connecting flex scanners together with yacc parsers - -Options - flex command-line options, and the "%option" directive - -Performance Considerations - how to make your scanner go as fast as possible - -Generating C++ Scanners - the (experimental) facility for generating C++ scanner classes - -Incompatibilities With Lex And POSIX - how flex differs from AT&T lex and the POSIX lex standard - -Diagnostics - those error messages produced by flex (or scanners it generates) - whose meanings might not be apparent - -Files - files used by flex - -Deficiencies / Bugs - known problems with flex - -See Also - other documentation, related tools - -Author - includes contact information - - -File: flex.info, Node: Description, Next: Examples, Prev: Overview, Up: Top - -Description -=========== - - `flex' is a tool for generating "scanners": programs which -recognized lexical patterns in text. `flex' reads the given input -files, or its standard input if no file names are given, for a -description of a scanner to generate. The description is in the form -of pairs of regular expressions and C code, called "rules". `flex' -generates as output a C source file, `lex.yy.c', which defines a -routine `yylex()'. This file is compiled and linked with the `-lfl' -library to produce an executable. When the executable is run, it -analyzes its input for occurrences of the regular expressions. -Whenever it finds one, it executes the corresponding C code. - - -File: flex.info, Node: Examples, Next: Format, Prev: Description, Up: Top - -Some simple examples -==================== - - First some simple examples to get the flavor of how one uses `flex'. -The following `flex' input specifies a scanner which whenever it -encounters the string "username" will replace it with the user's login -name: - - %% - username printf( "%s", getlogin() ); - - By default, any text not matched by a `flex' scanner is copied to -the output, so the net effect of this scanner is to copy its input file -to its output with each occurrence of "username" expanded. In this -input, there is just one rule. "username" is the PATTERN and the -"printf" is the ACTION. The "%%" marks the beginning of the rules. - - Here's another simple example: - - int num_lines = 0, num_chars = 0; - - %% - \n ++num_lines; ++num_chars; - . ++num_chars; - - %% - main() - { - yylex(); - printf( "# of lines = %d, # of chars = %d\n", - num_lines, num_chars ); - } - - This scanner counts the number of characters and the number of lines -in its input (it produces no output other than the final report on the -counts). The first line declares two globals, "num_lines" and -"num_chars", which are accessible both inside `yylex()' and in the -`main()' routine declared after the second "%%". There are two rules, -one which matches a newline ("\n") and increments both the line count -and the character count, and one which matches any character other than -a newline (indicated by the "." regular expression). - - A somewhat more complicated example: - - /* scanner for a toy Pascal-like language */ - - %{ - /* need this for the call to atof() below */ - #include - %} - - DIGIT [0-9] - ID [a-z][a-z0-9]* - - %% - - {DIGIT}+ { - printf( "An integer: %s (%d)\n", yytext, - atoi( yytext ) ); - } - - {DIGIT}+"."{DIGIT}* { - printf( "A float: %s (%g)\n", yytext, - atof( yytext ) ); - } - - if|then|begin|end|procedure|function { - printf( "A keyword: %s\n", yytext ); - } - - {ID} printf( "An identifier: %s\n", yytext ); - - "+"|"-"|"*"|"/" printf( "An operator: %s\n", yytext ); - - "{"[^}\n]*"}" /* eat up one-line comments */ - - [ \t\n]+ /* eat up whitespace */ - - . printf( "Unrecognized character: %s\n", yytext ); - - %% - - main( argc, argv ) - int argc; - char **argv; - { - ++argv, --argc; /* skip over program name */ - if ( argc > 0 ) - yyin = fopen( argv[0], "r" ); - else - yyin = stdin; - - yylex(); - } - - This is the beginnings of a simple scanner for a language like -Pascal. It identifies different types of TOKENS and reports on what it -has seen. - - The details of this example will be explained in the following -sections. - - -File: flex.info, Node: Format, Next: Patterns, Prev: Examples, Up: Top - -Format of the input file -======================== - - The `flex' input file consists of three sections, separated by a -line with just `%%' in it: - - definitions - %% - rules - %% - user code - - The "definitions" section contains declarations of simple "name" -definitions to simplify the scanner specification, and declarations of -"start conditions", which are explained in a later section. Name -definitions have the form: - - name definition - - The "name" is a word beginning with a letter or an underscore ('_') -followed by zero or more letters, digits, '_', or '-' (dash). The -definition is taken to begin at the first non-white-space character -following the name and continuing to the end of the line. The -definition can subsequently be referred to using "{name}", which will -expand to "(definition)". For example, - - DIGIT [0-9] - ID [a-z][a-z0-9]* - -defines "DIGIT" to be a regular expression which matches a single -digit, and "ID" to be a regular expression which matches a letter -followed by zero-or-more letters-or-digits. A subsequent reference to - - {DIGIT}+"."{DIGIT}* - -is identical to - - ([0-9])+"."([0-9])* - -and matches one-or-more digits followed by a '.' followed by -zero-or-more digits. - - The RULES section of the `flex' input contains a series of rules of -the form: - - pattern action - -where the pattern must be unindented and the action must begin on the -same line. - - See below for a further description of patterns and actions. - - Finally, the user code section is simply copied to `lex.yy.c' -verbatim. It is used for companion routines which call or are called -by the scanner. The presence of this section is optional; if it is -missing, the second `%%' in the input file may be skipped, too. - - In the definitions and rules sections, any *indented* text or text -enclosed in `%{' and `%}' is copied verbatim to the output (with the -`%{}''s removed). The `%{}''s must appear unindented on lines by -themselves. - - In the rules section, any indented or %{} text appearing before the -first rule may be used to declare variables which are local to the -scanning routine and (after the declarations) code which is to be -executed whenever the scanning routine is entered. Other indented or -%{} text in the rule section is still copied to the output, but its -meaning is not well-defined and it may well cause compile-time errors -(this feature is present for `POSIX' compliance; see below for other -such features). - - In the definitions section (but not in the rules section), an -unindented comment (i.e., a line beginning with "/*") is also copied -verbatim to the output up to the next "*/". - - -File: flex.info, Node: Patterns, Next: Matching, Prev: Format, Up: Top - -Patterns -======== - - The patterns in the input are written using an extended set of -regular expressions. These are: - -`x' - match the character `x' - -`.' - any character (byte) except newline - -`[xyz]' - a "character class"; in this case, the pattern matches either an - `x', a `y', or a `z' - -`[abj-oZ]' - a "character class" with a range in it; matches an `a', a `b', any - letter from `j' through `o', or a `Z' - -`[^A-Z]' - a "negated character class", i.e., any character but those in the - class. In this case, any character EXCEPT an uppercase letter. - -`[^A-Z\n]' - any character EXCEPT an uppercase letter or a newline - -`R*' - zero or more R's, where R is any regular expression - -`R+' - one or more R's - -`R?' - zero or one R's (that is, "an optional R") - -`R{2,5}' - anywhere from two to five R's - -`R{2,}' - two or more R's - -`R{4}' - exactly 4 R's - -`{NAME}' - the expansion of the "NAME" definition (see above) - -`"[xyz]\"foo"' - the literal string: `[xyz]"foo' - -`\X' - if X is an `a', `b', `f', `n', `r', `t', or `v', then the ANSI-C - interpretation of \X. Otherwise, a literal `X' (used to escape - operators such as `*') - -`\0' - a NUL character (ASCII code 0) - -`\123' - the character with octal value 123 - -`\x2a' - the character with hexadecimal value `2a' - -`(R)' - match an R; parentheses are used to override precedence (see below) - -`RS' - the regular expression R followed by the regular expression S; - called "concatenation" - -`R|S' - either an R or an S - -`R/S' - an R but only if it is followed by an S. The text matched by S is - included when determining whether this rule is the "longest - match", but is then returned to the input before the action is - executed. So the action only sees the text matched by R. This - type of pattern is called "trailing context". (There are some - combinations of `R/S' that `flex' cannot match correctly; see - notes in the Deficiencies / Bugs section below regarding - "dangerous trailing context".) - -`^R' - an R, but only at the beginning of a line (i.e., which just - starting to scan, or right after a newline has been scanned). - -`R$' - an R, but only at the end of a line (i.e., just before a newline). - Equivalent to "R/\n". - - Note that flex's notion of "newline" is exactly whatever the C - compiler used to compile flex interprets '\n' as; in particular, - on some DOS systems you must either filter out \r's in the input - yourself, or explicitly use R/\r\n for "r$". - -`R' - an R, but only in start condition S (see below for discussion of - start conditions) R same, but in any of start conditions - S1, S2, or S3 - -`<*>R' - an R in any start condition, even an exclusive one. - -`<>' - an end-of-file <> an end-of-file when in start - condition S1 or S2 - - Note that inside of a character class, all regular expression -operators lose their special meaning except escape ('\') and the -character class operators, '-', ']', and, at the beginning of the -class, '^'. - - The regular expressions listed above are grouped according to -precedence, from highest precedence at the top to lowest at the bottom. -Those grouped together have equal precedence. For example, - - foo|bar* - -is the same as - - (foo)|(ba(r*)) - -since the '*' operator has higher precedence than concatenation, and -concatenation higher than alternation ('|'). This pattern therefore -matches *either* the string "foo" *or* the string "ba" followed by -zero-or-more r's. To match "foo" or zero-or-more "bar"'s, use: - - foo|(bar)* - -and to match zero-or-more "foo"'s-or-"bar"'s: - - (foo|bar)* - - In addition to characters and ranges of characters, character -classes can also contain character class "expressions". These are -expressions enclosed inside `[': and `:'] delimiters (which themselves -must appear between the '[' and ']' of the character class; other -elements may occur inside the character class, too). The valid -expressions are: - - [:alnum:] [:alpha:] [:blank:] - [:cntrl:] [:digit:] [:graph:] - [:lower:] [:print:] [:punct:] - [:space:] [:upper:] [:xdigit:] - - These expressions all designate a set of characters equivalent to -the corresponding standard C `isXXX' function. For example, -`[:alnum:]' designates those characters for which `isalnum()' returns -true - i.e., any alphabetic or numeric. Some systems don't provide -`isblank()', so flex defines `[:blank:]' as a blank or a tab. - - For example, the following character classes are all equivalent: - - [[:alnum:]] - [[:alpha:][:digit:] - [[:alpha:]0-9] - [a-zA-Z0-9] - - If your scanner is case-insensitive (the `-i' flag), then -`[:upper:]' and `[:lower:]' are equivalent to `[:alpha:]'. - - Some notes on patterns: - - - A negated character class such as the example "[^A-Z]" above *will - match a newline* unless "\n" (or an equivalent escape sequence) is - one of the characters explicitly present in the negated character - class (e.g., "[^A-Z\n]"). This is unlike how many other regular - expression tools treat negated character classes, but - unfortunately the inconsistency is historically entrenched. - Matching newlines means that a pattern like [^"]* can match the - entire input unless there's another quote in the input. - - - A rule can have at most one instance of trailing context (the '/' - operator or the '$' operator). The start condition, '^', and - "<>" patterns can only occur at the beginning of a pattern, - and, as well as with '/' and '$', cannot be grouped inside - parentheses. A '^' which does not occur at the beginning of a - rule or a '$' which does not occur at the end of a rule loses its - special properties and is treated as a normal character. - - The following are illegal: - - foo/bar$ - foobar - - Note that the first of these, can be written "foo/bar\n". - - The following will result in '$' or '^' being treated as a normal - character: - - foo|(bar$) - foo|^bar - - If what's wanted is a "foo" or a bar-followed-by-a-newline, the - following could be used (the special '|' action is explained - below): - - foo | - bar$ /* action goes here */ - - A similar trick will work for matching a foo or a - bar-at-the-beginning-of-a-line. - - -File: flex.info, Node: Matching, Next: Actions, Prev: Patterns, Up: Top - -How the input is matched -======================== - - When the generated scanner is run, it analyzes its input looking for -strings which match any of its patterns. If it finds more than one -match, it takes the one matching the most text (for trailing context -rules, this includes the length of the trailing part, even though it -will then be returned to the input). If it finds two or more matches -of the same length, the rule listed first in the `flex' input file is -chosen. - - Once the match is determined, the text corresponding to the match -(called the TOKEN) is made available in the global character pointer -`yytext', and its length in the global integer `yyleng'. The ACTION -corresponding to the matched pattern is then executed (a more detailed -description of actions follows), and then the remaining input is -scanned for another match. - - If no match is found, then the "default rule" is executed: the next -character in the input is considered matched and copied to the standard -output. Thus, the simplest legal `flex' input is: - - %% - - which generates a scanner that simply copies its input (one -character at a time) to its output. - - Note that `yytext' can be defined in two different ways: either as a -character *pointer* or as a character *array*. You can control which -definition `flex' uses by including one of the special directives -`%pointer' or `%array' in the first (definitions) section of your flex -input. The default is `%pointer', unless you use the `-l' lex -compatibility option, in which case `yytext' will be an array. The -advantage of using `%pointer' is substantially faster scanning and no -buffer overflow when matching very large tokens (unless you run out of -dynamic memory). The disadvantage is that you are restricted in how -your actions can modify `yytext' (see the next section), and calls to -the `unput()' function destroys the present contents of `yytext', which -can be a considerable porting headache when moving between different -`lex' versions. - - The advantage of `%array' is that you can then modify `yytext' to -your heart's content, and calls to `unput()' do not destroy `yytext' -(see below). Furthermore, existing `lex' programs sometimes access -`yytext' externally using declarations of the form: - extern char yytext[]; - This definition is erroneous when used with `%pointer', but correct -for `%array'. - - `%array' defines `yytext' to be an array of `YYLMAX' characters, -which defaults to a fairly large value. You can change the size by -simply #define'ing `YYLMAX' to a different value in the first section -of your `flex' input. As mentioned above, with `%pointer' yytext grows -dynamically to accommodate large tokens. While this means your -`%pointer' scanner can accommodate very large tokens (such as matching -entire blocks of comments), bear in mind that each time the scanner -must resize `yytext' it also must rescan the entire token from the -beginning, so matching such tokens can prove slow. `yytext' presently -does *not* dynamically grow if a call to `unput()' results in too much -text being pushed back; instead, a run-time error results. - - Also note that you cannot use `%array' with C++ scanner classes (the -`c++' option; see below). - - -File: flex.info, Node: Actions, Next: Generated scanner, Prev: Matching, Up: Top - -Actions -======= - - Each pattern in a rule has a corresponding action, which can be any -arbitrary C statement. The pattern ends at the first non-escaped -whitespace character; the remainder of the line is its action. If the -action is empty, then when the pattern is matched the input token is -simply discarded. For example, here is the specification for a program -which deletes all occurrences of "zap me" from its input: - - %% - "zap me" - - (It will copy all other characters in the input to the output since -they will be matched by the default rule.) - - Here is a program which compresses multiple blanks and tabs down to -a single blank, and throws away whitespace found at the end of a line: - - %% - [ \t]+ putchar( ' ' ); - [ \t]+$ /* ignore this token */ - - If the action contains a '{', then the action spans till the -balancing '}' is found, and the action may cross multiple lines. -`flex' knows about C strings and comments and won't be fooled by braces -found within them, but also allows actions to begin with `%{' and will -consider the action to be all the text up to the next `%}' (regardless -of ordinary braces inside the action). - - An action consisting solely of a vertical bar ('|') means "same as -the action for the next rule." See below for an illustration. - - Actions can include arbitrary C code, including `return' statements -to return a value to whatever routine called `yylex()'. Each time -`yylex()' is called it continues processing tokens from where it last -left off until it either reaches the end of the file or executes a -return. - - Actions are free to modify `yytext' except for lengthening it -(adding characters to its end-these will overwrite later characters in -the input stream). This however does not apply when using `%array' -(see above); in that case, `yytext' may be freely modified in any way. - - Actions are free to modify `yyleng' except they should not do so if -the action also includes use of `yymore()' (see below). - - There are a number of special directives which can be included -within an action: - - - `ECHO' copies yytext to the scanner's output. - - - `BEGIN' followed by the name of a start condition places the - scanner in the corresponding start condition (see below). - - - `REJECT' directs the scanner to proceed on to the "second best" - rule which matched the input (or a prefix of the input). The rule - is chosen as described above in "How the Input is Matched", and - `yytext' and `yyleng' set up appropriately. It may either be one - which matched as much text as the originally chosen rule but came - later in the `flex' input file, or one which matched less text. - For example, the following will both count the words in the input - and call the routine special() whenever "frob" is seen: - - int word_count = 0; - %% - - frob special(); REJECT; - [^ \t\n]+ ++word_count; - - Without the `REJECT', any "frob"'s in the input would not be - counted as words, since the scanner normally executes only one - action per token. Multiple `REJECT's' are allowed, each one - finding the next best choice to the currently active rule. For - example, when the following scanner scans the token "abcd", it - will write "abcdabcaba" to the output: - - %% - a | - ab | - abc | - abcd ECHO; REJECT; - .|\n /* eat up any unmatched character */ - - (The first three rules share the fourth's action since they use - the special '|' action.) `REJECT' is a particularly expensive - feature in terms of scanner performance; if it is used in *any* of - the scanner's actions it will slow down *all* of the scanner's - matching. Furthermore, `REJECT' cannot be used with the `-Cf' or - `-CF' options (see below). - - Note also that unlike the other special actions, `REJECT' is a - *branch*; code immediately following it in the action will *not* - be executed. - - - `yymore()' tells the scanner that the next time it matches a rule, - the corresponding token should be *appended* onto the current - value of `yytext' rather than replacing it. For example, given - the input "mega-kludge" the following will write - "mega-mega-kludge" to the output: - - %% - mega- ECHO; yymore(); - kludge ECHO; - - First "mega-" is matched and echoed to the output. Then "kludge" - is matched, but the previous "mega-" is still hanging around at - the beginning of `yytext' so the `ECHO' for the "kludge" rule will - actually write "mega-kludge". - - Two notes regarding use of `yymore()'. First, `yymore()' depends on -the value of `yyleng' correctly reflecting the size of the current -token, so you must not modify `yyleng' if you are using `yymore()'. -Second, the presence of `yymore()' in the scanner's action entails a -minor performance penalty in the scanner's matching speed. - - - `yyless(n)' returns all but the first N characters of the current - token back to the input stream, where they will be rescanned when - the scanner looks for the next match. `yytext' and `yyleng' are - adjusted appropriately (e.g., `yyleng' will now be equal to N ). - For example, on the input "foobar" the following will write out - "foobarbar": - - %% - foobar ECHO; yyless(3); - [a-z]+ ECHO; - - An argument of 0 to `yyless' will cause the entire current input - string to be scanned again. Unless you've changed how the scanner - will subsequently process its input (using `BEGIN', for example), - this will result in an endless loop. - - Note that `yyless' is a macro and can only be used in the flex - input file, not from other source files. - - - `unput(c)' puts the character `c' back onto the input stream. It - will be the next character scanned. The following action will - take the current token and cause it to be rescanned enclosed in - parentheses. - - { - int i; - /* Copy yytext because unput() trashes yytext */ - char *yycopy = strdup( yytext ); - unput( ')' ); - for ( i = yyleng - 1; i >= 0; --i ) - unput( yycopy[i] ); - unput( '(' ); - free( yycopy ); - } - - Note that since each `unput()' puts the given character back at - the *beginning* of the input stream, pushing back strings must be - done back-to-front. An important potential problem when using - `unput()' is that if you are using `%pointer' (the default), a - call to `unput()' *destroys* the contents of `yytext', starting - with its rightmost character and devouring one character to the - left with each call. If you need the value of yytext preserved - after a call to `unput()' (as in the above example), you must - either first copy it elsewhere, or build your scanner using - `%array' instead (see How The Input Is Matched). - - Finally, note that you cannot put back `EOF' to attempt to mark - the input stream with an end-of-file. - - - `input()' reads the next character from the input stream. For - example, the following is one way to eat up C comments: - - %% - "/*" { - register int c; - - for ( ; ; ) - { - while ( (c = input()) != '*' && - c != EOF ) - ; /* eat up text of comment */ - - if ( c == '*' ) - { - while ( (c = input()) == '*' ) - ; - if ( c == '/' ) - break; /* found the end */ - } - - if ( c == EOF ) - { - error( "EOF in comment" ); - break; - } - } - } - - (Note that if the scanner is compiled using `C++', then `input()' - is instead referred to as `yyinput()', in order to avoid a name - clash with the `C++' stream by the name of `input'.) - - - YY_FLUSH_BUFFER flushes the scanner's internal buffer so that the - next time the scanner attempts to match a token, it will first - refill the buffer using `YY_INPUT' (see The Generated Scanner, - below). This action is a special case of the more general - `yy_flush_buffer()' function, described below in the section - Multiple Input Buffers. - - - `yyterminate()' can be used in lieu of a return statement in an - action. It terminates the scanner and returns a 0 to the - scanner's caller, indicating "all done". By default, - `yyterminate()' is also called when an end-of-file is encountered. - It is a macro and may be redefined. - - -File: flex.info, Node: Generated scanner, Next: Start conditions, Prev: Actions, Up: Top - -The generated scanner -===================== - - The output of `flex' is the file `lex.yy.c', which contains the -scanning routine `yylex()', a number of tables used by it for matching -tokens, and a number of auxiliary routines and macros. By default, -`yylex()' is declared as follows: - - int yylex() - { - ... various definitions and the actions in here ... - } - - (If your environment supports function prototypes, then it will be -"int yylex( void )".) This definition may be changed by defining -the "YY_DECL" macro. For example, you could use: - - #define YY_DECL float lexscan( a, b ) float a, b; - - to give the scanning routine the name `lexscan', returning a float, -and taking two floats as arguments. Note that if you give arguments to -the scanning routine using a K&R-style/non-prototyped function -declaration, you must terminate the definition with a semi-colon (`;'). - - Whenever `yylex()' is called, it scans tokens from the global input -file `yyin' (which defaults to stdin). It continues until it either -reaches an end-of-file (at which point it returns the value 0) or one -of its actions executes a `return' statement. - - If the scanner reaches an end-of-file, subsequent calls are undefined -unless either `yyin' is pointed at a new input file (in which case -scanning continues from that file), or `yyrestart()' is called. -`yyrestart()' takes one argument, a `FILE *' pointer (which can be nil, -if you've set up `YY_INPUT' to scan from a source other than `yyin'), -and initializes `yyin' for scanning from that file. Essentially there -is no difference between just assigning `yyin' to a new input file or -using `yyrestart()' to do so; the latter is available for compatibility -with previous versions of `flex', and because it can be used to switch -input files in the middle of scanning. It can also be used to throw -away the current input buffer, by calling it with an argument of -`yyin'; but better is to use `YY_FLUSH_BUFFER' (see above). Note that -`yyrestart()' does *not* reset the start condition to `INITIAL' (see -Start Conditions, below). - - If `yylex()' stops scanning due to executing a `return' statement in -one of the actions, the scanner may then be called again and it will -resume scanning where it left off. - - By default (and for purposes of efficiency), the scanner uses -block-reads rather than simple `getc()' calls to read characters from -`yyin'. The nature of how it gets its input can be controlled by -defining the `YY_INPUT' macro. YY_INPUT's calling sequence is -"YY_INPUT(buf,result,max_size)". Its action is to place up to MAX_SIZE -characters in the character array BUF and return in the integer -variable RESULT either the number of characters read or the constant -YY_NULL (0 on Unix systems) to indicate EOF. The default YY_INPUT -reads from the global file-pointer "yyin". - - A sample definition of YY_INPUT (in the definitions section of the -input file): - - %{ - #define YY_INPUT(buf,result,max_size) \ - { \ - int c = getchar(); \ - result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \ - } - %} - - This definition will change the input processing to occur one -character at a time. - - When the scanner receives an end-of-file indication from YY_INPUT, -it then checks the `yywrap()' function. If `yywrap()' returns false -(zero), then it is assumed that the function has gone ahead and set up -`yyin' to point to another input file, and scanning continues. If it -returns true (non-zero), then the scanner terminates, returning 0 to -its caller. Note that in either case, the start condition remains -unchanged; it does *not* revert to `INITIAL'. - - If you do not supply your own version of `yywrap()', then you must -either use `%option noyywrap' (in which case the scanner behaves as -though `yywrap()' returned 1), or you must link with `-lfl' to obtain -the default version of the routine, which always returns 1. - - Three routines are available for scanning from in-memory buffers -rather than files: `yy_scan_string()', `yy_scan_bytes()', and -`yy_scan_buffer()'. See the discussion of them below in the section -Multiple Input Buffers. - - The scanner writes its `ECHO' output to the `yyout' global (default, -stdout), which may be redefined by the user simply by assigning it to -some other `FILE' pointer. - - -File: flex.info, Node: Start conditions, Next: Multiple buffers, Prev: Generated scanner, Up: Top - -Start conditions -================ - - `flex' provides a mechanism for conditionally activating rules. Any -rule whose pattern is prefixed with "" will only be active when the -scanner is in the start condition named "sc". For example, - - [^"]* { /* eat up the string body ... */ - ... - } - -will be active only when the scanner is in the "STRING" start -condition, and - - \. { /* handle an escape ... */ - ... - } - -will be active only when the current start condition is either -"INITIAL", "STRING", or "QUOTE". - - Start conditions are declared in the definitions (first) section of -the input using unindented lines beginning with either `%s' or `%x' -followed by a list of names. The former declares *inclusive* start -conditions, the latter *exclusive* start conditions. A start condition -is activated using the `BEGIN' action. Until the next `BEGIN' action is -executed, rules with the given start condition will be active and rules -with other start conditions will be inactive. If the start condition -is *inclusive*, then rules with no start conditions at all will also be -active. If it is *exclusive*, then *only* rules qualified with the -start condition will be active. A set of rules contingent on the same -exclusive start condition describe a scanner which is independent of -any of the other rules in the `flex' input. Because of this, exclusive -start conditions make it easy to specify "mini-scanners" which scan -portions of the input that are syntactically different from the rest -(e.g., comments). - - If the distinction between inclusive and exclusive start conditions -is still a little vague, here's a simple example illustrating the -connection between the two. The set of rules: - - %s example - %% - - foo do_something(); - - bar something_else(); - -is equivalent to - - %x example - %% - - foo do_something(); - - bar something_else(); - - Without the `' qualifier, the `bar' pattern in the -second example wouldn't be active (i.e., couldn't match) when in start -condition `example'. If we just used `' to qualify `bar', -though, then it would only be active in `example' and not in `INITIAL', -while in the first example it's active in both, because in the first -example the `example' starting condition is an *inclusive* (`%s') start -condition. - - Also note that the special start-condition specifier `<*>' matches -every start condition. Thus, the above example could also have been -written; - - %x example - %% - - foo do_something(); - - <*>bar something_else(); - - The default rule (to `ECHO' any unmatched character) remains active -in start conditions. It is equivalent to: - - <*>.|\\n ECHO; - - `BEGIN(0)' returns to the original state where only the rules with -no start conditions are active. This state can also be referred to as -the start-condition "INITIAL", so `BEGIN(INITIAL)' is equivalent to -`BEGIN(0)'. (The parentheses around the start condition name are not -required but are considered good style.) - - `BEGIN' actions can also be given as indented code at the beginning -of the rules section. For example, the following will cause the -scanner to enter the "SPECIAL" start condition whenever `yylex()' is -called and the global variable `enter_special' is true: - - int enter_special; - - %x SPECIAL - %% - if ( enter_special ) - BEGIN(SPECIAL); - - blahblahblah - ...more rules follow... - - To illustrate the uses of start conditions, here is a scanner which -provides two different interpretations of a string like "123.456". By -default it will treat it as as three tokens, the integer "123", a dot -('.'), and the integer "456". But if the string is preceded earlier in -the line by the string "expect-floats" it will treat it as a single -token, the floating-point number 123.456: - - %{ - #include - %} - %s expect - - %% - expect-floats BEGIN(expect); - - [0-9]+"."[0-9]+ { - printf( "found a float, = %f\n", - atof( yytext ) ); - } - \n { - /* that's the end of the line, so - * we need another "expect-number" - * before we'll recognize any more - * numbers - */ - BEGIN(INITIAL); - } - - [0-9]+ { - - Version 2.5 December 1994 18 - - printf( "found an integer, = %d\n", - atoi( yytext ) ); - } - - "." printf( "found a dot\n" ); - - Here is a scanner which recognizes (and discards) C comments while -maintaining a count of the current input line. - - %x comment - %% - int line_num = 1; - - "/*" BEGIN(comment); - - [^*\n]* /* eat anything that's not a '*' */ - "*"+[^*/\n]* /* eat up '*'s not followed by '/'s */ - \n ++line_num; - "*"+"/" BEGIN(INITIAL); - - This scanner goes to a bit of trouble to match as much text as -possible with each rule. In general, when attempting to write a -high-speed scanner try to match as much possible in each rule, as it's -a big win. - - Note that start-conditions names are really integer values and can -be stored as such. Thus, the above could be extended in the following -fashion: - - %x comment foo - %% - int line_num = 1; - int comment_caller; - - "/*" { - comment_caller = INITIAL; - BEGIN(comment); - } - - ... - - "/*" { - comment_caller = foo; - BEGIN(comment); - } - - [^*\n]* /* eat anything that's not a '*' */ - "*"+[^*/\n]* /* eat up '*'s not followed by '/'s */ - \n ++line_num; - "*"+"/" BEGIN(comment_caller); - - Furthermore, you can access the current start condition using the -integer-valued `YY_START' macro. For example, the above assignments to -`comment_caller' could instead be written - - comment_caller = YY_START; - - Flex provides `YYSTATE' as an alias for `YY_START' (since that is -what's used by AT&T `lex'). - - Note that start conditions do not have their own name-space; %s's -and %x's declare names in the same fashion as #define's. - - Finally, here's an example of how to match C-style quoted strings -using exclusive start conditions, including expanded escape sequences -(but not including checking for a string that's too long): - - %x str - - %% - char string_buf[MAX_STR_CONST]; - char *string_buf_ptr; - - \" string_buf_ptr = string_buf; BEGIN(str); - - \" { /* saw closing quote - all done */ - BEGIN(INITIAL); - *string_buf_ptr = '\0'; - /* return string constant token type and - * value to parser - */ - } - - \n { - /* error - unterminated string constant */ - /* generate error message */ - } - - \\[0-7]{1,3} { - /* octal escape sequence */ - int result; - - (void) sscanf( yytext + 1, "%o", &result ); - - if ( result > 0xff ) - /* error, constant is out-of-bounds */ - - *string_buf_ptr++ = result; - } - - \\[0-9]+ { - /* generate error - bad escape sequence; something - * like '\48' or '\0777777' - */ - } - - \\n *string_buf_ptr++ = '\n'; - \\t *string_buf_ptr++ = '\t'; - \\r *string_buf_ptr++ = '\r'; - \\b *string_buf_ptr++ = '\b'; - \\f *string_buf_ptr++ = '\f'; - - \\(.|\n) *string_buf_ptr++ = yytext[1]; - - [^\\\n\"]+ { - char *yptr = yytext; - - while ( *yptr ) - *string_buf_ptr++ = *yptr++; - } - - Often, such as in some of the examples above, you wind up writing a -whole bunch of rules all preceded by the same start condition(s). Flex -makes this a little easier and cleaner by introducing a notion of start -condition "scope". A start condition scope is begun with: - - { - -where SCs is a list of one or more start conditions. Inside the start -condition scope, every rule automatically has the prefix `' -applied to it, until a `}' which matches the initial `{'. So, for -example, - - { - "\\n" return '\n'; - "\\r" return '\r'; - "\\f" return '\f'; - "\\0" return '\0'; - } - -is equivalent to: - - "\\n" return '\n'; - "\\r" return '\r'; - "\\f" return '\f'; - "\\0" return '\0'; - - Start condition scopes may be nested. - - Three routines are available for manipulating stacks of start -conditions: - -`void yy_push_state(int new_state)' - pushes the current start condition onto the top of the start - condition stack and switches to NEW_STATE as though you had used - `BEGIN new_state' (recall that start condition names are also - integers). - -`void yy_pop_state()' - pops the top of the stack and switches to it via `BEGIN'. - -`int yy_top_state()' - returns the top of the stack without altering the stack's contents. - - The start condition stack grows dynamically and so has no built-in -size limitation. If memory is exhausted, program execution aborts. - - To use start condition stacks, your scanner must include a `%option -stack' directive (see Options below). - - -File: flex.info, Node: Multiple buffers, Next: End-of-file rules, Prev: Start conditions, Up: Top - -Multiple input buffers -====================== - - Some scanners (such as those which support "include" files) require -reading from several input streams. As `flex' scanners do a large -amount of buffering, one cannot control where the next input will be -read from by simply writing a `YY_INPUT' which is sensitive to the -scanning context. `YY_INPUT' is only called when the scanner reaches -the end of its buffer, which may be a long time after scanning a -statement such as an "include" which requires switching the input -source. - - To negotiate these sorts of problems, `flex' provides a mechanism -for creating and switching between multiple input buffers. An input -buffer is created by using: - - YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) - -which takes a `FILE' pointer and a size and creates a buffer associated -with the given file and large enough to hold SIZE characters (when in -doubt, use `YY_BUF_SIZE' for the size). It returns a `YY_BUFFER_STATE' -handle, which may then be passed to other routines (see below). The -`YY_BUFFER_STATE' type is a pointer to an opaque `struct' -`yy_buffer_state' structure, so you may safely initialize -YY_BUFFER_STATE variables to `((YY_BUFFER_STATE) 0)' if you wish, and -also refer to the opaque structure in order to correctly declare input -buffers in source files other than that of your scanner. Note that the -`FILE' pointer in the call to `yy_create_buffer' is only used as the -value of `yyin' seen by `YY_INPUT'; if you redefine `YY_INPUT' so it no -longer uses `yyin', then you can safely pass a nil `FILE' pointer to -`yy_create_buffer'. You select a particular buffer to scan from using: - - void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) - - switches the scanner's input buffer so subsequent tokens will come -from NEW_BUFFER. Note that `yy_switch_to_buffer()' may be used by -`yywrap()' to set things up for continued scanning, instead of opening -a new file and pointing `yyin' at it. Note also that switching input -sources via either `yy_switch_to_buffer()' or `yywrap()' does *not* -change the start condition. - - void yy_delete_buffer( YY_BUFFER_STATE buffer ) - -is used to reclaim the storage associated with a buffer. You can also -clear the current contents of a buffer using: - - void yy_flush_buffer( YY_BUFFER_STATE buffer ) - - This function discards the buffer's contents, so the next time the -scanner attempts to match a token from the buffer, it will first fill -the buffer anew using `YY_INPUT'. - - `yy_new_buffer()' is an alias for `yy_create_buffer()', provided for -compatibility with the C++ use of `new' and `delete' for creating and -destroying dynamic objects. - - Finally, the `YY_CURRENT_BUFFER' macro returns a `YY_BUFFER_STATE' -handle to the current buffer. - - Here is an example of using these features for writing a scanner -which expands include files (the `<>' feature is discussed below): - - /* the "incl" state is used for picking up the name - * of an include file - */ - %x incl - - %{ - #define MAX_INCLUDE_DEPTH 10 - YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH]; - int include_stack_ptr = 0; - %} - - %% - include BEGIN(incl); - - [a-z]+ ECHO; - [^a-z\n]*\n? ECHO; - - [ \t]* /* eat the whitespace */ - [^ \t\n]+ { /* got the include file name */ - if ( include_stack_ptr >= MAX_INCLUDE_DEPTH ) - { - fprintf( stderr, "Includes nested too deeply" ); - exit( 1 ); - } - - include_stack[include_stack_ptr++] = - YY_CURRENT_BUFFER; - - yyin = fopen( yytext, "r" ); - - if ( ! yyin ) - error( ... ); - - yy_switch_to_buffer( - yy_create_buffer( yyin, YY_BUF_SIZE ) ); - - BEGIN(INITIAL); - } - - <> { - if ( --include_stack_ptr < 0 ) - { - yyterminate(); - } - - else - { - yy_delete_buffer( YY_CURRENT_BUFFER ); - yy_switch_to_buffer( - include_stack[include_stack_ptr] ); - } - } - - Three routines are available for setting up input buffers for -scanning in-memory strings instead of files. All of them create a new -input buffer for scanning the string, and return a corresponding -`YY_BUFFER_STATE' handle (which you should delete with -`yy_delete_buffer()' when done with it). They also switch to the new -buffer using `yy_switch_to_buffer()', so the next call to `yylex()' will -start scanning the string. - -`yy_scan_string(const char *str)' - scans a NUL-terminated string. - -`yy_scan_bytes(const char *bytes, int len)' - scans `len' bytes (including possibly NUL's) starting at location - BYTES. - - Note that both of these functions create and scan a *copy* of the -string or bytes. (This may be desirable, since `yylex()' modifies the -contents of the buffer it is scanning.) You can avoid the copy by using: - -`yy_scan_buffer(char *base, yy_size_t size)' - which scans in place the buffer starting at BASE, consisting of - SIZE bytes, the last two bytes of which *must* be - `YY_END_OF_BUFFER_CHAR' (ASCII NUL). These last two bytes are not - scanned; thus, scanning consists of `base[0]' through - `base[size-2]', inclusive. - - If you fail to set up BASE in this manner (i.e., forget the final - two `YY_END_OF_BUFFER_CHAR' bytes), then `yy_scan_buffer()' - returns a nil pointer instead of creating a new input buffer. - - The type `yy_size_t' is an integral type to which you can cast an - integer expression reflecting the size of the buffer. - - -File: flex.info, Node: End-of-file rules, Next: Miscellaneous, Prev: Multiple buffers, Up: Top - -End-of-file rules -================= - - The special rule "<>" indicates actions which are to be taken -when an end-of-file is encountered and yywrap() returns non-zero (i.e., -indicates no further files to process). The action must finish by -doing one of four things: - - - assigning `yyin' to a new input file (in previous versions of - flex, after doing the assignment you had to call the special - action `YY_NEW_FILE'; this is no longer necessary); - - - executing a `return' statement; - - - executing the special `yyterminate()' action; - - - or, switching to a new buffer using `yy_switch_to_buffer()' as - shown in the example above. - - <> rules may not be used with other patterns; they may only be -qualified with a list of start conditions. If an unqualified <> -rule is given, it applies to *all* start conditions which do not -already have <> actions. To specify an <> rule for only the -initial start condition, use - - <> - - These rules are useful for catching things like unclosed comments. -An example: - - %x quote - %% - - ...other rules for dealing with quotes... - - <> { - error( "unterminated quote" ); - yyterminate(); - } - <> { - if ( *++filelist ) - yyin = fopen( *filelist, "r" ); - else - yyterminate(); - } - - -File: flex.info, Node: Miscellaneous, Next: User variables, Prev: End-of-file rules, Up: Top - -Miscellaneous macros -==================== - - The macro `YY_USER_ACTION' can be defined to provide an action which -is always executed prior to the matched rule's action. For example, it -could be #define'd to call a routine to convert yytext to lower-case. -When `YY_USER_ACTION' is invoked, the variable `yy_act' gives the -number of the matched rule (rules are numbered starting with 1). -Suppose you want to profile how often each of your rules is matched. -The following would do the trick: - - #define YY_USER_ACTION ++ctr[yy_act] - - where `ctr' is an array to hold the counts for the different rules. -Note that the macro `YY_NUM_RULES' gives the total number of rules -(including the default rule, even if you use `-s', so a correct -declaration for `ctr' is: - - int ctr[YY_NUM_RULES]; - - The macro `YY_USER_INIT' may be defined to provide an action which -is always executed before the first scan (and before the scanner's -internal initializations are done). For example, it could be used to -call a routine to read in a data table or open a logging file. - - The macro `yy_set_interactive(is_interactive)' can be used to -control whether the current buffer is considered *interactive*. An -interactive buffer is processed more slowly, but must be used when the -scanner's input source is indeed interactive to avoid problems due to -waiting to fill buffers (see the discussion of the `-I' flag below). A -non-zero value in the macro invocation marks the buffer as interactive, -a zero value as non-interactive. Note that use of this macro overrides -`%option always-interactive' or `%option never-interactive' (see -Options below). `yy_set_interactive()' must be invoked prior to -beginning to scan the buffer that is (or is not) to be considered -interactive. - - The macro `yy_set_bol(at_bol)' can be used to control whether the -current buffer's scanning context for the next token match is done as -though at the beginning of a line. A non-zero macro argument makes -rules anchored with - - The macro `YY_AT_BOL()' returns true if the next token scanned from -the current buffer will have '^' rules active, false otherwise. - - In the generated scanner, the actions are all gathered in one large -switch statement and separated using `YY_BREAK', which may be -redefined. By default, it is simply a "break", to separate each rule's -action from the following rule's. Redefining `YY_BREAK' allows, for -example, C++ users to #define YY_BREAK to do nothing (while being very -careful that every rule ends with a "break" or a "return"!) to avoid -suffering from unreachable statement warnings where because a rule's -action ends with "return", the `YY_BREAK' is inaccessible. - - -File: flex.info, Node: User variables, Next: YACC interface, Prev: Miscellaneous, Up: Top - -Values available to the user -============================ - - This section summarizes the various values available to the user in -the rule actions. - - - `char *yytext' holds the text of the current token. It may be - modified but not lengthened (you cannot append characters to the - end). - - If the special directive `%array' appears in the first section of - the scanner description, then `yytext' is instead declared `char - yytext[YYLMAX]', where `YYLMAX' is a macro definition that you can - redefine in the first section if you don't like the default value - (generally 8KB). Using `%array' results in somewhat slower - scanners, but the value of `yytext' becomes immune to calls to - `input()' and `unput()', which potentially destroy its value when - `yytext' is a character pointer. The opposite of `%array' is - `%pointer', which is the default. - - You cannot use `%array' when generating C++ scanner classes (the - `-+' flag). - - - `int yyleng' holds the length of the current token. - - - `FILE *yyin' is the file which by default `flex' reads from. It - may be redefined but doing so only makes sense before scanning - begins or after an EOF has been encountered. Changing it in the - midst of scanning will have unexpected results since `flex' - buffers its input; use `yyrestart()' instead. Once scanning - terminates because an end-of-file has been seen, you can assign - `yyin' at the new input file and then call the scanner again to - continue scanning. - - - `void yyrestart( FILE *new_file )' may be called to point `yyin' - at the new input file. The switch-over to the new file is - immediate (any previously buffered-up input is lost). Note that - calling `yyrestart()' with `yyin' as an argument thus throws away - the current input buffer and continues scanning the same input - file. - - - `FILE *yyout' is the file to which `ECHO' actions are done. It - can be reassigned by the user. - - - `YY_CURRENT_BUFFER' returns a `YY_BUFFER_STATE' handle to the - current buffer. - - - `YY_START' returns an integer value corresponding to the current - start condition. You can subsequently use this value with `BEGIN' - to return to that start condition. - - -File: flex.info, Node: YACC interface, Next: Options, Prev: User variables, Up: Top - -Interfacing with `yacc' -======================= - - One of the main uses of `flex' is as a companion to the `yacc' -parser-generator. `yacc' parsers expect to call a routine named -`yylex()' to find the next input token. The routine is supposed to -return the type of the next token as well as putting any associated -value in the global `yylval'. To use `flex' with `yacc', one specifies -the `-d' option to `yacc' to instruct it to generate the file `y.tab.h' -containing definitions of all the `%tokens' appearing in the `yacc' -input. This file is then included in the `flex' scanner. For example, -if one of the tokens is "TOK_NUMBER", part of the scanner might look -like: - - %{ - #include "y.tab.h" - %} - - %% - - [0-9]+ yylval = atoi( yytext ); return TOK_NUMBER; - - -File: flex.info, Node: Options, Next: Performance, Prev: YACC interface, Up: Top - -Options -======= - - `flex' has the following options: - -`-b' - Generate backing-up information to `lex.backup'. This is a list - of scanner states which require backing up and the input - characters on which they do so. By adding rules one can remove - backing-up states. If *all* backing-up states are eliminated and - `-Cf' or `-CF' is used, the generated scanner will run faster (see - the `-p' flag). Only users who wish to squeeze every last cycle - out of their scanners need worry about this option. (See the - section on Performance Considerations below.) - -`-c' - is a do-nothing, deprecated option included for POSIX compliance. - -`-d' - makes the generated scanner run in "debug" mode. Whenever a - pattern is recognized and the global `yy_flex_debug' is non-zero - (which is the default), the scanner will write to `stderr' a line - of the form: - - --accepting rule at line 53 ("the matched text") - - The line number refers to the location of the rule in the file - defining the scanner (i.e., the file that was fed to flex). - Messages are also generated when the scanner backs up, accepts the - default rule, reaches the end of its input buffer (or encounters a - NUL; at this point, the two look the same as far as the scanner's - concerned), or reaches an end-of-file. - -`-f' - specifies "fast scanner". No table compression is done and stdio - is bypassed. The result is large but fast. This option is - equivalent to `-Cfr' (see below). - -`-h' - generates a "help" summary of `flex's' options to `stdout' and - then exits. `-?' and `--help' are synonyms for `-h'. - -`-i' - instructs `flex' to generate a *case-insensitive* scanner. The - case of letters given in the `flex' input patterns will be - ignored, and tokens in the input will be matched regardless of - case. The matched text given in `yytext' will have the preserved - case (i.e., it will not be folded). - -`-l' - turns on maximum compatibility with the original AT&T `lex' - implementation. Note that this does not mean *full* - compatibility. Use of this option costs a considerable amount of - performance, and it cannot be used with the `-+, -f, -F, -Cf', or - `-CF' options. For details on the compatibilities it provides, see - the section "Incompatibilities With Lex And POSIX" below. This - option also results in the name `YY_FLEX_LEX_COMPAT' being - #define'd in the generated scanner. - -`-n' - is another do-nothing, deprecated option included only for POSIX - compliance. - -`-p' - generates a performance report to stderr. The report consists of - comments regarding features of the `flex' input file which will - cause a serious loss of performance in the resulting scanner. If - you give the flag twice, you will also get comments regarding - features that lead to minor performance losses. - - Note that the use of `REJECT', `%option yylineno' and variable - trailing context (see the Deficiencies / Bugs section below) - entails a substantial performance penalty; use of `yymore()', the - `^' operator, and the `-I' flag entail minor performance penalties. - -`-s' - causes the "default rule" (that unmatched scanner input is echoed - to `stdout') to be suppressed. If the scanner encounters input - that does not match any of its rules, it aborts with an error. - This option is useful for finding holes in a scanner's rule set. - -`-t' - instructs `flex' to write the scanner it generates to standard - output instead of `lex.yy.c'. - -`-v' - specifies that `flex' should write to `stderr' a summary of - statistics regarding the scanner it generates. Most of the - statistics are meaningless to the casual `flex' user, but the - first line identifies the version of `flex' (same as reported by - `-V'), and the next line the flags used when generating the - scanner, including those that are on by default. - -`-w' - suppresses warning messages. - -`-B' - instructs `flex' to generate a *batch* scanner, the opposite of - *interactive* scanners generated by `-I' (see below). In general, - you use `-B' when you are *certain* that your scanner will never - be used interactively, and you want to squeeze a *little* more - performance out of it. If your goal is instead to squeeze out a - *lot* more performance, you should be using the `-Cf' or `-CF' - options (discussed below), which turn on `-B' automatically anyway. - -`-F' - specifies that the "fast" scanner table representation should be - used (and stdio bypassed). This representation is about as fast - as the full table representation `(-f)', and for some sets of - patterns will be considerably smaller (and for others, larger). - In general, if the pattern set contains both "keywords" and a - catch-all, "identifier" rule, such as in the set: - - "case" return TOK_CASE; - "switch" return TOK_SWITCH; - ... - "default" return TOK_DEFAULT; - [a-z]+ return TOK_ID; - - then you're better off using the full table representation. If - only the "identifier" rule is present and you then use a hash - table or some such to detect the keywords, you're better off using - `-F'. - - This option is equivalent to `-CFr' (see below). It cannot be - used with `-+'. - -`-I' - instructs `flex' to generate an *interactive* scanner. An - interactive scanner is one that only looks ahead to decide what - token has been matched if it absolutely must. It turns out that - always looking one extra character ahead, even if the scanner has - already seen enough text to disambiguate the current token, is a - bit faster than only looking ahead when necessary. But scanners - that always look ahead give dreadful interactive performance; for - example, when a user types a newline, it is not recognized as a - newline token until they enter *another* token, which often means - typing in another whole line. - - `Flex' scanners default to *interactive* unless you use the `-Cf' - or `-CF' table-compression options (see below). That's because if - you're looking for high-performance you should be using one of - these options, so if you didn't, `flex' assumes you'd rather trade - off a bit of run-time performance for intuitive interactive - behavior. Note also that you *cannot* use `-I' in conjunction - with `-Cf' or `-CF'. Thus, this option is not really needed; it - is on by default for all those cases in which it is allowed. - - You can force a scanner to *not* be interactive by using `-B' (see - above). - -`-L' - instructs `flex' not to generate `#line' directives. Without this - option, `flex' peppers the generated scanner with #line directives - so error messages in the actions will be correctly located with - respect to either the original `flex' input file (if the errors - are due to code in the input file), or `lex.yy.c' (if the errors - are `flex's' fault - you should report these sorts of errors to - the email address given below). - -`-T' - makes `flex' run in `trace' mode. It will generate a lot of - messages to `stderr' concerning the form of the input and the - resultant non-deterministic and deterministic finite automata. - This option is mostly for use in maintaining `flex'. - -`-V' - prints the version number to `stdout' and exits. `--version' is a - synonym for `-V'. - -`-7' - instructs `flex' to generate a 7-bit scanner, i.e., one which can - only recognized 7-bit characters in its input. The advantage of - using `-7' is that the scanner's tables can be up to half the size - of those generated using the `-8' option (see below). The - disadvantage is that such scanners often hang or crash if their - input contains an 8-bit character. - - Note, however, that unless you generate your scanner using the - `-Cf' or `-CF' table compression options, use of `-7' will save - only a small amount of table space, and make your scanner - considerably less portable. `Flex's' default behavior is to - generate an 8-bit scanner unless you use the `-Cf' or `-CF', in - which case `flex' defaults to generating 7-bit scanners unless - your site was always configured to generate 8-bit scanners (as - will often be the case with non-USA sites). You can tell whether - flex generated a 7-bit or an 8-bit scanner by inspecting the flag - summary in the `-v' output as described above. - - Note that if you use `-Cfe' or `-CFe' (those table compression - options, but also using equivalence classes as discussed see - below), flex still defaults to generating an 8-bit scanner, since - usually with these compression options full 8-bit tables are not - much more expensive than 7-bit tables. - -`-8' - instructs `flex' to generate an 8-bit scanner, i.e., one which can - recognize 8-bit characters. This flag is only needed for scanners - generated using `-Cf' or `-CF', as otherwise flex defaults to - generating an 8-bit scanner anyway. - - See the discussion of `-7' above for flex's default behavior and - the tradeoffs between 7-bit and 8-bit scanners. - -`-+' - specifies that you want flex to generate a C++ scanner class. See - the section on Generating C++ Scanners below for details. - -`-C[aefFmr]' - controls the degree of table compression and, more generally, - trade-offs between small scanners and fast scanners. - - `-Ca' ("align") instructs flex to trade off larger tables in the - generated scanner for faster performance because the elements of - the tables are better aligned for memory access and computation. - On some RISC architectures, fetching and manipulating long-words - is more efficient than with smaller-sized units such as - shortwords. This option can double the size of the tables used by - your scanner. - - `-Ce' directs `flex' to construct "equivalence classes", i.e., - sets of characters which have identical lexical properties (for - example, if the only appearance of digits in the `flex' input is - in the character class "[0-9]" then the digits '0', '1', ..., '9' - will all be put in the same equivalence class). Equivalence - classes usually give dramatic reductions in the final table/object - file sizes (typically a factor of 2-5) and are pretty cheap - performance-wise (one array look-up per character scanned). - - `-Cf' specifies that the *full* scanner tables should be generated - - `flex' should not compress the tables by taking advantages of - similar transition functions for different states. - - `-CF' specifies that the alternate fast scanner representation - (described above under the `-F' flag) should be used. This option - cannot be used with `-+'. - - `-Cm' directs `flex' to construct "meta-equivalence classes", - which are sets of equivalence classes (or characters, if - equivalence classes are not being used) that are commonly used - together. Meta-equivalence classes are often a big win when using - compressed tables, but they have a moderate performance impact - (one or two "if" tests and one array look-up per character - scanned). - - `-Cr' causes the generated scanner to *bypass* use of the standard - I/O library (stdio) for input. Instead of calling `fread()' or - `getc()', the scanner will use the `read()' system call, resulting - in a performance gain which varies from system to system, but in - general is probably negligible unless you are also using `-Cf' or - `-CF'. Using `-Cr' can cause strange behavior if, for example, - you read from `yyin' using stdio prior to calling the scanner - (because the scanner will miss whatever text your previous reads - left in the stdio input buffer). - - `-Cr' has no effect if you define `YY_INPUT' (see The Generated - Scanner above). - - A lone `-C' specifies that the scanner tables should be compressed - but neither equivalence classes nor meta-equivalence classes - should be used. - - The options `-Cf' or `-CF' and `-Cm' do not make sense together - - there is no opportunity for meta-equivalence classes if the table - is not being compressed. Otherwise the options may be freely - mixed, and are cumulative. - - The default setting is `-Cem', which specifies that `flex' should - generate equivalence classes and meta-equivalence classes. This - setting provides the highest degree of table compression. You can - trade off faster-executing scanners at the cost of larger tables - with the following generally being true: - - slowest & smallest - -Cem - -Cm - -Ce - -C - -C{f,F}e - -C{f,F} - -C{f,F}a - fastest & largest - - Note that scanners with the smallest tables are usually generated - and compiled the quickest, so during development you will usually - want to use the default, maximal compression. - - `-Cfe' is often a good compromise between speed and size for - production scanners. - -`-ooutput' - directs flex to write the scanner to the file `out-' `put' instead - of `lex.yy.c'. If you combine `-o' with the `-t' option, then the - scanner is written to `stdout' but its `#line' directives (see the - `-L' option above) refer to the file `output'. - -`-Pprefix' - changes the default `yy' prefix used by `flex' for all - globally-visible variable and function names to instead be PREFIX. - For example, `-Pfoo' changes the name of `yytext' to `footext'. - It also changes the name of the default output file from - `lex.yy.c' to `lex.foo.c'. Here are all of the names affected: - - yy_create_buffer - yy_delete_buffer - yy_flex_debug - yy_init_buffer - yy_flush_buffer - yy_load_buffer_state - yy_switch_to_buffer - yyin - yyleng - yylex - yylineno - yyout - yyrestart - yytext - yywrap - - (If you are using a C++ scanner, then only `yywrap' and - `yyFlexLexer' are affected.) Within your scanner itself, you can - still refer to the global variables and functions using either - version of their name; but externally, they have the modified name. - - This option lets you easily link together multiple `flex' programs - into the same executable. Note, though, that using this option - also renames `yywrap()', so you now *must* either provide your own - (appropriately-named) version of the routine for your scanner, or - use `%option noyywrap', as linking with `-lfl' no longer provides - one for you by default. - -`-Sskeleton_file' - overrides the default skeleton file from which `flex' constructs - its scanners. You'll never need this option unless you are doing - `flex' maintenance or development. - - `flex' also provides a mechanism for controlling options within the -scanner specification itself, rather than from the flex command-line. -This is done by including `%option' directives in the first section of -the scanner specification. You can specify multiple options with a -single `%option' directive, and multiple directives in the first -section of your flex input file. Most options are given simply as -names, optionally preceded by the word "no" (with no intervening -whitespace) to negate their meaning. A number are equivalent to flex -flags or their negation: - - 7bit -7 option - 8bit -8 option - align -Ca option - backup -b option - batch -B option - c++ -+ option - - caseful or - case-sensitive opposite of -i (default) - - case-insensitive or - caseless -i option - - debug -d option - default opposite of -s option - ecs -Ce option - fast -F option - full -f option - interactive -I option - lex-compat -l option - meta-ecs -Cm option - perf-report -p option - read -Cr option - stdout -t option - verbose -v option - warn opposite of -w option - (use "%option nowarn" for -w) - - array equivalent to "%array" - pointer equivalent to "%pointer" (default) - - Some `%option's' provide features otherwise not available: - -`always-interactive' - instructs flex to generate a scanner which always considers its - input "interactive". Normally, on each new input file the scanner - calls `isatty()' in an attempt to determine whether the scanner's - input source is interactive and thus should be read a character at - a time. When this option is used, however, then no such call is - made. - -`main' - directs flex to provide a default `main()' program for the - scanner, which simply calls `yylex()'. This option implies - `noyywrap' (see below). - -`never-interactive' - instructs flex to generate a scanner which never considers its - input "interactive" (again, no call made to `isatty())'. This is - the opposite of `always-' *interactive*. - -`stack' - enables the use of start condition stacks (see Start Conditions - above). - -`stdinit' - if unset (i.e., `%option nostdinit') initializes `yyin' and - `yyout' to nil `FILE' pointers, instead of `stdin' and `stdout'. - -`yylineno' - directs `flex' to generate a scanner that maintains the number of - the current line read from its input in the global variable - `yylineno'. This option is implied by `%option lex-compat'. - -`yywrap' - if unset (i.e., `%option noyywrap'), makes the scanner not call - `yywrap()' upon an end-of-file, but simply assume that there are - no more files to scan (until the user points `yyin' at a new file - and calls `yylex()' again). - - `flex' scans your rule actions to determine whether you use the -`REJECT' or `yymore()' features. The `reject' and `yymore' options are -available to override its decision as to whether you use the options, -either by setting them (e.g., `%option reject') to indicate the feature -is indeed used, or unsetting them to indicate it actually is not used -(e.g., `%option noyymore'). - - Three options take string-delimited values, offset with '=': - - %option outfile="ABC" - -is equivalent to `-oABC', and - - %option prefix="XYZ" - -is equivalent to `-PXYZ'. - - Finally, - - %option yyclass="foo" - -only applies when generating a C++ scanner (`-+' option). It informs -`flex' that you have derived `foo' as a subclass of `yyFlexLexer' so -`flex' will place your actions in the member function `foo::yylex()' -instead of `yyFlexLexer::yylex()'. It also generates a -`yyFlexLexer::yylex()' member function that emits a run-time error (by -invoking `yyFlexLexer::LexerError()') if called. See Generating C++ -Scanners, below, for additional information. - - A number of options are available for lint purists who want to -suppress the appearance of unneeded routines in the generated scanner. -Each of the following, if unset, results in the corresponding routine -not appearing in the generated scanner: - - input, unput - yy_push_state, yy_pop_state, yy_top_state - yy_scan_buffer, yy_scan_bytes, yy_scan_string - -(though `yy_push_state()' and friends won't appear anyway unless you -use `%option stack'). - - -File: flex.info, Node: Performance, Next: C++, Prev: Options, Up: Top - -Performance considerations -========================== - - The main design goal of `flex' is that it generate high-performance -scanners. It has been optimized for dealing well with large sets of -rules. Aside from the effects on scanner speed of the table -compression `-C' options outlined above, there are a number of -options/actions which degrade performance. These are, from most -expensive to least: - - REJECT - %option yylineno - arbitrary trailing context - - pattern sets that require backing up - %array - %option interactive - %option always-interactive - - '^' beginning-of-line operator - yymore() - - with the first three all being quite expensive and the last two -being quite cheap. Note also that `unput()' is implemented as a -routine call that potentially does quite a bit of work, while -`yyless()' is a quite-cheap macro; so if just putting back some excess -text you scanned, use `yyless()'. - - `REJECT' should be avoided at all costs when performance is -important. It is a particularly expensive option. - - Getting rid of backing up is messy and often may be an enormous -amount of work for a complicated scanner. In principal, one begins by -using the `-b' flag to generate a `lex.backup' file. For example, on -the input - - %% - foo return TOK_KEYWORD; - foobar return TOK_KEYWORD; - -the file looks like: - - State #6 is non-accepting - - associated rule line numbers: - 2 3 - out-transitions: [ o ] - jam-transitions: EOF [ \001-n p-\177 ] - - State #8 is non-accepting - - associated rule line numbers: - 3 - out-transitions: [ a ] - jam-transitions: EOF [ \001-` b-\177 ] - - State #9 is non-accepting - - associated rule line numbers: - 3 - out-transitions: [ r ] - jam-transitions: EOF [ \001-q s-\177 ] - - Compressed tables always back up. - - The first few lines tell us that there's a scanner state in which it -can make a transition on an 'o' but not on any other character, and -that in that state the currently scanned text does not match any rule. -The state occurs when trying to match the rules found at lines 2 and 3 -in the input file. If the scanner is in that state and then reads -something other than an 'o', it will have to back up to find a rule -which is matched. With a bit of head-scratching one can see that this -must be the state it's in when it has seen "fo". When this has -happened, if anything other than another 'o' is seen, the scanner will -have to back up to simply match the 'f' (by the default rule). - - The comment regarding State #8 indicates there's a problem when -"foob" has been scanned. Indeed, on any character other than an 'a', -the scanner will have to back up to accept "foo". Similarly, the -comment for State #9 concerns when "fooba" has been scanned and an 'r' -does not follow. - - The final comment reminds us that there's no point going to all the -trouble of removing backing up from the rules unless we're using `-Cf' -or `-CF', since there's no performance gain doing so with compressed -scanners. - - The way to remove the backing up is to add "error" rules: - - %% - foo return TOK_KEYWORD; - foobar return TOK_KEYWORD; - - fooba | - foob | - fo { - /* false alarm, not really a keyword */ - return TOK_ID; - } - - Eliminating backing up among a list of keywords can also be done -using a "catch-all" rule: - - %% - foo return TOK_KEYWORD; - foobar return TOK_KEYWORD; - - [a-z]+ return TOK_ID; - - This is usually the best solution when appropriate. - - Backing up messages tend to cascade. With a complicated set of -rules it's not uncommon to get hundreds of messages. If one can -decipher them, though, it often only takes a dozen or so rules to -eliminate the backing up (though it's easy to make a mistake and have -an error rule accidentally match a valid token. A possible future -`flex' feature will be to automatically add rules to eliminate backing -up). - - It's important to keep in mind that you gain the benefits of -eliminating backing up only if you eliminate *every* instance of -backing up. Leaving just one means you gain nothing. - - VARIABLE trailing context (where both the leading and trailing parts -do not have a fixed length) entails almost the same performance loss as -`REJECT' (i.e., substantial). So when possible a rule like: - - %% - mouse|rat/(cat|dog) run(); - -is better written: - - %% - mouse/cat|dog run(); - rat/cat|dog run(); - -or as - - %% - mouse|rat/cat run(); - mouse|rat/dog run(); - - Note that here the special '|' action does *not* provide any -savings, and can even make things worse (see Deficiencies / Bugs below). - - Another area where the user can increase a scanner's performance -(and one that's easier to implement) arises from the fact that the -longer the tokens matched, the faster the scanner will run. This is -because with long tokens the processing of most input characters takes -place in the (short) inner scanning loop, and does not often have to go -through the additional work of setting up the scanning environment -(e.g., `yytext') for the action. Recall the scanner for C comments: - - %x comment - %% - int line_num = 1; - - "/*" BEGIN(comment); - - [^*\n]* - "*"+[^*/\n]* - \n ++line_num; - "*"+"/" BEGIN(INITIAL); - - This could be sped up by writing it as: - - %x comment - %% - int line_num = 1; - - "/*" BEGIN(comment); - - [^*\n]* - [^*\n]*\n ++line_num; - "*"+[^*/\n]* - "*"+[^*/\n]*\n ++line_num; - "*"+"/" BEGIN(INITIAL); - - Now instead of each newline requiring the processing of another -action, recognizing the newlines is "distributed" over the other rules -to keep the matched text as long as possible. Note that *adding* rules -does *not* slow down the scanner! The speed of the scanner is -independent of the number of rules or (modulo the considerations given -at the beginning of this section) how complicated the rules are with -regard to operators such as '*' and '|'. - - A final example in speeding up a scanner: suppose you want to scan -through a file containing identifiers and keywords, one per line and -with no other extraneous characters, and recognize all the keywords. A -natural first approach is: - - %% - asm | - auto | - break | - ... etc ... - volatile | - while /* it's a keyword */ - - .|\n /* it's not a keyword */ - - To eliminate the back-tracking, introduce a catch-all rule: - - %% - asm | - auto | - break | - ... etc ... - volatile | - while /* it's a keyword */ - - [a-z]+ | - .|\n /* it's not a keyword */ - - Now, if it's guaranteed that there's exactly one word per line, then -we can reduce the total number of matches by a half by merging in the -recognition of newlines with that of the other tokens: - - %% - asm\n | - auto\n | - break\n | - ... etc ... - volatile\n | - while\n /* it's a keyword */ - - [a-z]+\n | - .|\n /* it's not a keyword */ - - One has to be careful here, as we have now reintroduced backing up -into the scanner. In particular, while *we* know that there will never -be any characters in the input stream other than letters or newlines, -`flex' can't figure this out, and it will plan for possibly needing to -back up when it has scanned a token like "auto" and then the next -character is something other than a newline or a letter. Previously it -would then just match the "auto" rule and be done, but now it has no -"auto" rule, only a "auto\n" rule. To eliminate the possibility of -backing up, we could either duplicate all rules but without final -newlines, or, since we never expect to encounter such an input and -therefore don't how it's classified, we can introduce one more -catch-all rule, this one which doesn't include a newline: - - %% - asm\n | - auto\n | - break\n | - ... etc ... - volatile\n | - while\n /* it's a keyword */ - - [a-z]+\n | - [a-z]+ | - .|\n /* it's not a keyword */ - - Compiled with `-Cf', this is about as fast as one can get a `flex' -scanner to go for this particular problem. - - A final note: `flex' is slow when matching NUL's, particularly when -a token contains multiple NUL's. It's best to write rules which match -*short* amounts of text if it's anticipated that the text will often -include NUL's. - - Another final note regarding performance: as mentioned above in the -section How the Input is Matched, dynamically resizing `yytext' to -accommodate huge tokens is a slow process because it presently requires -that the (huge) token be rescanned from the beginning. Thus if -performance is vital, you should attempt to match "large" quantities of -text but not "huge" quantities, where the cutoff between the two is at -about 8K characters/token. - - -File: flex.info, Node: C++, Next: Incompatibilities, Prev: Performance, Up: Top - -Generating C++ scanners -======================= - - `flex' provides two different ways to generate scanners for use with -C++. The first way is to simply compile a scanner generated by `flex' -using a C++ compiler instead of a C compiler. You should not encounter -any compilations errors (please report any you find to the email address -given in the Author section below). You can then use C++ code in your -rule actions instead of C code. Note that the default input source for -your scanner remains `yyin', and default echoing is still done to -`yyout'. Both of these remain `FILE *' variables and not C++ `streams'. - - You can also use `flex' to generate a C++ scanner class, using the -`-+' option, (or, equivalently, `%option c++'), which is automatically -specified if the name of the flex executable ends in a `+', such as -`flex++'. When using this option, flex defaults to generating the -scanner to the file `lex.yy.cc' instead of `lex.yy.c'. The generated -scanner includes the header file `FlexLexer.h', which defines the -interface to two C++ classes. - - The first class, `FlexLexer', provides an abstract base class -defining the general scanner class interface. It provides the -following member functions: - -`const char* YYText()' - returns the text of the most recently matched token, the - equivalent of `yytext'. - -`int YYLeng()' - returns the length of the most recently matched token, the - equivalent of `yyleng'. - -`int lineno() const' - returns the current input line number (see `%option yylineno'), or - 1 if `%option yylineno' was not used. - -`void set_debug( int flag )' - sets the debugging flag for the scanner, equivalent to assigning to - `yy_flex_debug' (see the Options section above). Note that you - must build the scanner using `%option debug' to include debugging - information in it. - -`int debug() const' - returns the current setting of the debugging flag. - - Also provided are member functions equivalent to -`yy_switch_to_buffer(), yy_create_buffer()' (though the first argument -is an `istream*' object pointer and not a `FILE*', `yy_flush_buffer()', -`yy_delete_buffer()', and `yyrestart()' (again, the first argument is a -`istream*' object pointer). - - The second class defined in `FlexLexer.h' is `yyFlexLexer', which is -derived from `FlexLexer'. It defines the following additional member -functions: - -`yyFlexLexer( istream* arg_yyin = 0, ostream* arg_yyout = 0 )' - constructs a `yyFlexLexer' object using the given streams for - input and output. If not specified, the streams default to `cin' - and `cout', respectively. - -`virtual int yylex()' - performs the same role is `yylex()' does for ordinary flex - scanners: it scans the input stream, consuming tokens, until a - rule's action returns a value. If you derive a subclass S from - `yyFlexLexer' and want to access the member functions and - variables of S inside `yylex()', then you need to use `%option - yyclass="S"' to inform `flex' that you will be using that subclass - instead of `yyFlexLexer'. In this case, rather than generating - `yyFlexLexer::yylex()', `flex' generates `S::yylex()' (and also - generates a dummy `yyFlexLexer::yylex()' that calls - `yyFlexLexer::LexerError()' if called). - -`virtual void switch_streams(istream* new_in = 0, ostream* new_out = 0)' - reassigns `yyin' to `new_in' (if non-nil) and `yyout' to `new_out' - (ditto), deleting the previous input buffer if `yyin' is - reassigned. - -`int yylex( istream* new_in = 0, ostream* new_out = 0 )' - first switches the input streams via `switch_streams( new_in, - new_out )' and then returns the value of `yylex()'. - - In addition, `yyFlexLexer' defines the following protected virtual -functions which you can redefine in derived classes to tailor the -scanner: - -`virtual int LexerInput( char* buf, int max_size )' - reads up to `max_size' characters into BUF and returns the number - of characters read. To indicate end-of-input, return 0 - characters. Note that "interactive" scanners (see the `-B' and - `-I' flags) define the macro `YY_INTERACTIVE'. If you redefine - `LexerInput()' and need to take different actions depending on - whether or not the scanner might be scanning an interactive input - source, you can test for the presence of this name via `#ifdef'. - -`virtual void LexerOutput( const char* buf, int size )' - writes out SIZE characters from the buffer BUF, which, while - NUL-terminated, may also contain "internal" NUL's if the scanner's - rules can match text with NUL's in them. - -`virtual void LexerError( const char* msg )' - reports a fatal error message. The default version of this - function writes the message to the stream `cerr' and exits. - - Note that a `yyFlexLexer' object contains its *entire* scanning -state. Thus you can use such objects to create reentrant scanners. -You can instantiate multiple instances of the same `yyFlexLexer' class, -and you can also combine multiple C++ scanner classes together in the -same program using the `-P' option discussed above. Finally, note that -the `%array' feature is not available to C++ scanner classes; you must -use `%pointer' (the default). - - Here is an example of a simple C++ scanner: - - // An example of using the flex C++ scanner class. - - %{ - int mylineno = 0; - %} - - string \"[^\n"]+\" - - ws [ \t]+ - - alpha [A-Za-z] - dig [0-9] - name ({alpha}|{dig}|\$)({alpha}|{dig}|[_.\-/$])* - num1 [-+]?{dig}+\.?([eE][-+]?{dig}+)? - num2 [-+]?{dig}*\.{dig}+([eE][-+]?{dig}+)? - number {num1}|{num2} - - %% - - {ws} /* skip blanks and tabs */ - - "/*" { - int c; - - while((c = yyinput()) != 0) - { - if(c == '\n') - ++mylineno; - - else if(c == '*') - { - if((c = yyinput()) == '/') - break; - else - unput(c); - } - } - } - - {number} cout << "number " << YYText() << '\n'; - - \n mylineno++; - - {name} cout << "name " << YYText() << '\n'; - - {string} cout << "string " << YYText() << '\n'; - - %% - - Version 2.5 December 1994 44 - - int main( int /* argc */, char** /* argv */ ) - { - FlexLexer* lexer = new yyFlexLexer; - while(lexer->yylex() != 0) - ; - return 0; - } - - If you want to create multiple (different) lexer classes, you use -the `-P' flag (or the `prefix=' option) to rename each `yyFlexLexer' to -some other `xxFlexLexer'. You then can include `' in your -other sources once per lexer class, first renaming `yyFlexLexer' as -follows: - - #undef yyFlexLexer - #define yyFlexLexer xxFlexLexer - #include - - #undef yyFlexLexer - #define yyFlexLexer zzFlexLexer - #include - - if, for example, you used `%option prefix="xx"' for one of your -scanners and `%option prefix="zz"' for the other. - - IMPORTANT: the present form of the scanning class is *experimental* -and may change considerably between major releases. - - -File: flex.info, Node: Incompatibilities, Next: Diagnostics, Prev: C++, Up: Top - -Incompatibilities with `lex' and POSIX -====================================== - - `flex' is a rewrite of the AT&T Unix `lex' tool (the two -implementations do not share any code, though), with some extensions -and incompatibilities, both of which are of concern to those who wish -to write scanners acceptable to either implementation. Flex is fully -compliant with the POSIX `lex' specification, except that when using -`%pointer' (the default), a call to `unput()' destroys the contents of -`yytext', which is counter to the POSIX specification. - - In this section we discuss all of the known areas of incompatibility -between flex, AT&T lex, and the POSIX specification. - - `flex's' `-l' option turns on maximum compatibility with the -original AT&T `lex' implementation, at the cost of a major loss in the -generated scanner's performance. We note below which incompatibilities -can be overcome using the `-l' option. - - `flex' is fully compatible with `lex' with the following exceptions: - - - The undocumented `lex' scanner internal variable `yylineno' is not - supported unless `-l' or `%option yylineno' is used. `yylineno' - should be maintained on a per-buffer basis, rather than a - per-scanner (single global variable) basis. `yylineno' is not - part of the POSIX specification. - - - The `input()' routine is not redefinable, though it may be called - to read characters following whatever has been matched by a rule. - If `input()' encounters an end-of-file the normal `yywrap()' - processing is done. A "real" end-of-file is returned by `input()' - as `EOF'. - - Input is instead controlled by defining the `YY_INPUT' macro. - - The `flex' restriction that `input()' cannot be redefined is in - accordance with the POSIX specification, which simply does not - specify any way of controlling the scanner's input other than by - making an initial assignment to `yyin'. - - - The `unput()' routine is not redefinable. This restriction is in - accordance with POSIX. - - - `flex' scanners are not as reentrant as `lex' scanners. In - particular, if you have an interactive scanner and an interrupt - handler which long-jumps out of the scanner, and the scanner is - subsequently called again, you may get the following message: - - fatal flex scanner internal error--end of buffer missed - - To reenter the scanner, first use - - yyrestart( yyin ); - - Note that this call will throw away any buffered input; usually - this isn't a problem with an interactive scanner. - - Also note that flex C++ scanner classes *are* reentrant, so if - using C++ is an option for you, you should use them instead. See - "Generating C++ Scanners" above for details. - - - `output()' is not supported. Output from the `ECHO' macro is done - to the file-pointer `yyout' (default `stdout'). - - `output()' is not part of the POSIX specification. - - - `lex' does not support exclusive start conditions (%x), though - they are in the POSIX specification. - - - When definitions are expanded, `flex' encloses them in - parentheses. With lex, the following: - - NAME [A-Z][A-Z0-9]* - %% - foo{NAME}? printf( "Found it\n" ); - %% - - will not match the string "foo" because when the macro is expanded - the rule is equivalent to "foo[A-Z][A-Z0-9]*?" and the precedence - is such that the '?' is associated with "[A-Z0-9]*". With `flex', - the rule will be expanded to "foo([A-Z][A-Z0-9]*)?" and so the - string "foo" will match. - - Note that if the definition begins with `^' or ends with `$' then - it is *not* expanded with parentheses, to allow these operators to - appear in definitions without losing their special meanings. But - the `, /', and `<>' operators cannot be used in a `flex' - definition. - - Using `-l' results in the `lex' behavior of no parentheses around - the definition. - - The POSIX specification is that the definition be enclosed in - parentheses. - - - Some implementations of `lex' allow a rule's action to begin on a - separate line, if the rule's pattern has trailing whitespace: - - %% - foo|bar - { foobar_action(); } - - `flex' does not support this feature. - - - The `lex' `%r' (generate a Ratfor scanner) option is not - supported. It is not part of the POSIX specification. - - - After a call to `unput()', `yytext' is undefined until the next - token is matched, unless the scanner was built using `%array'. - This is not the case with `lex' or the POSIX specification. The - `-l' option does away with this incompatibility. - - - The precedence of the `{}' (numeric range) operator is different. - `lex' interprets "abc{1,3}" as "match one, two, or three - occurrences of 'abc'", whereas `flex' interprets it as "match 'ab' - followed by one, two, or three occurrences of 'c'". The latter is - in agreement with the POSIX specification. - - - The precedence of the `^' operator is different. `lex' interprets - "^foo|bar" as "match either 'foo' at the beginning of a line, or - 'bar' anywhere", whereas `flex' interprets it as "match either - 'foo' or 'bar' if they come at the beginning of a line". The - latter is in agreement with the POSIX specification. - - - The special table-size declarations such as `%a' supported by - `lex' are not required by `flex' scanners; `flex' ignores them. - - - The name FLEX_SCANNER is #define'd so scanners may be written for - use with either `flex' or `lex'. Scanners also include - `YY_FLEX_MAJOR_VERSION' and `YY_FLEX_MINOR_VERSION' indicating - which version of `flex' generated the scanner (for example, for the - 2.5 release, these defines would be 2 and 5 respectively). - - The following `flex' features are not included in `lex' or the POSIX -specification: - - C++ scanners - %option - start condition scopes - start condition stacks - interactive/non-interactive scanners - yy_scan_string() and friends - yyterminate() - yy_set_interactive() - yy_set_bol() - YY_AT_BOL() - <> - <*> - YY_DECL - YY_START - YY_USER_ACTION - YY_USER_INIT - #line directives - %{}'s around actions - multiple actions on a line - -plus almost all of the flex flags. The last feature in the list refers -to the fact that with `flex' you can put multiple actions on the same -line, separated with semicolons, while with `lex', the following - - foo handle_foo(); ++num_foos_seen; - -is (rather surprisingly) truncated to - - foo handle_foo(); - - `flex' does not truncate the action. Actions that are not enclosed -in braces are simply terminated at the end of the line. - - -File: flex.info, Node: Diagnostics, Next: Files, Prev: Incompatibilities, Up: Top - -Diagnostics -=========== - -`warning, rule cannot be matched' - indicates that the given rule cannot be matched because it follows - other rules that will always match the same text as it. For - example, in the following "foo" cannot be matched because it comes - after an identifier "catch-all" rule: - - [a-z]+ got_identifier(); - foo got_foo(); - - Using `REJECT' in a scanner suppresses this warning. - -`warning, -s option given but default rule can be matched' - means that it is possible (perhaps only in a particular start - condition) that the default rule (match any single character) is - the only one that will match a particular input. Since `-s' was - given, presumably this is not intended. - -`reject_used_but_not_detected undefined' -`yymore_used_but_not_detected undefined' - These errors can occur at compile time. They indicate that the - scanner uses `REJECT' or `yymore()' but that `flex' failed to - notice the fact, meaning that `flex' scanned the first two sections - looking for occurrences of these actions and failed to find any, - but somehow you snuck some in (via a #include file, for example). - Use `%option reject' or `%option yymore' to indicate to flex that - you really do use these features. - -`flex scanner jammed' - a scanner compiled with `-s' has encountered an input string which - wasn't matched by any of its rules. This error can also occur due - to internal problems. - -`token too large, exceeds YYLMAX' - your scanner uses `%array' and one of its rules matched a string - longer than the `YYL-' `MAX' constant (8K bytes by default). You - can increase the value by #define'ing `YYLMAX' in the definitions - section of your `flex' input. - -`scanner requires -8 flag to use the character 'X'' - Your scanner specification includes recognizing the 8-bit - character X and you did not specify the -8 flag, and your scanner - defaulted to 7-bit because you used the `-Cf' or `-CF' table - compression options. See the discussion of the `-7' flag for - details. - -`flex scanner push-back overflow' - you used `unput()' to push back so much text that the scanner's - buffer could not hold both the pushed-back text and the current - token in `yytext'. Ideally the scanner should dynamically resize - the buffer in this case, but at present it does not. - -`input buffer overflow, can't enlarge buffer because scanner uses REJECT' - the scanner was working on matching an extremely large token and - needed to expand the input buffer. This doesn't work with - scanners that use `REJECT'. - -`fatal flex scanner internal error--end of buffer missed' - This can occur in an scanner which is reentered after a long-jump - has jumped out (or over) the scanner's activation frame. Before - reentering the scanner, use: - - yyrestart( yyin ); - - or, as noted above, switch to using the C++ scanner class. - -`too many start conditions in <> construct!' - you listed more start conditions in a <> construct than exist (so - you must have listed at least one of them twice). - - -File: flex.info, Node: Files, Next: Deficiencies, Prev: Diagnostics, Up: Top - -Files -===== - -`-lfl' - library with which scanners must be linked. - -`lex.yy.c' - generated scanner (called `lexyy.c' on some systems). - -`lex.yy.cc' - generated C++ scanner class, when using `-+'. - -`' - header file defining the C++ scanner base class, `FlexLexer', and - its derived class, `yyFlexLexer'. - -`flex.skl' - skeleton scanner. This file is only used when building flex, not - when flex executes. - -`lex.backup' - backing-up information for `-b' flag (called `lex.bck' on some - systems). - - -File: flex.info, Node: Deficiencies, Next: See also, Prev: Files, Up: Top - -Deficiencies / Bugs -=================== - - Some trailing context patterns cannot be properly matched and -generate warning messages ("dangerous trailing context"). These are -patterns where the ending of the first part of the rule matches the -beginning of the second part, such as "zx*/xy*", where the 'x*' matches -the 'x' at the beginning of the trailing context. (Note that the POSIX -draft states that the text matched by such patterns is undefined.) - - For some trailing context rules, parts which are actually -fixed-length are not recognized as such, leading to the abovementioned -performance loss. In particular, parts using '|' or {n} (such as -"foo{3}") are always considered variable-length. - - Combining trailing context with the special '|' action can result in -*fixed* trailing context being turned into the more expensive VARIABLE -trailing context. For example, in the following: - - %% - abc | - xyz/def - - Use of `unput()' invalidates yytext and yyleng, unless the `%array' -directive or the `-l' option has been used. - - Pattern-matching of NUL's is substantially slower than matching -other characters. - - Dynamic resizing of the input buffer is slow, as it entails -rescanning all the text matched so far by the current (generally huge) -token. - - Due to both buffering of input and read-ahead, you cannot intermix -calls to routines, such as, for example, `getchar()', with -`flex' rules and expect it to work. Call `input()' instead. - - The total table entries listed by the `-v' flag excludes the number -of table entries needed to determine what rule has been matched. The -number of entries is equal to the number of DFA states if the scanner -does not use `REJECT', and somewhat greater than the number of states -if it does. - - `REJECT' cannot be used with the `-f' or `-F' options. - - The `flex' internal algorithms need documentation. - - -File: flex.info, Node: See also, Next: Author, Prev: Deficiencies, Up: Top - -See also -======== - - `lex'(1), `yacc'(1), `sed'(1), `awk'(1). - - John Levine, Tony Mason, and Doug Brown: Lex & Yacc; O'Reilly and -Associates. Be sure to get the 2nd edition. - - M. E. Lesk and E. Schmidt, LEX - Lexical Analyzer Generator. - - Alfred Aho, Ravi Sethi and Jeffrey Ullman: Compilers: Principles, -Techniques and Tools; Addison-Wesley (1986). Describes the -pattern-matching techniques used by `flex' (deterministic finite -automata). - - -File: flex.info, Node: Author, Prev: See also, Up: Top - -Author -====== - - Vern Paxson, with the help of many ideas and much inspiration from -Van Jacobson. Original version by Jef Poskanzer. The fast table -representation is a partial implementation of a design done by Van -Jacobson. The implementation was done by Kevin Gong and Vern Paxson. - - Thanks to the many `flex' beta-testers, feedbackers, and -contributors, especially Francois Pinard, Casey Leedom, Stan Adermann, -Terry Allen, David Barker-Plummer, John Basrai, Nelson H.F. Beebe, -`benson@odi.com', Karl Berry, Peter A. Bigot, Simon Blanchard, Keith -Bostic, Frederic Brehm, Ian Brockbank, Kin Cho, Nick Christopher, Brian -Clapper, J.T. Conklin, Jason Coughlin, Bill Cox, Nick Cropper, Dave -Curtis, Scott David Daniels, Chris G. Demetriou, Theo Deraadt, Mike -Donahue, Chuck Doucette, Tom Epperly, Leo Eskin, Chris Faylor, Chris -Flatters, Jon Forrest, Joe Gayda, Kaveh R. Ghazi, Eric Goldman, -Christopher M. Gould, Ulrich Grepel, Peer Griebel, Jan Hajic, Charles -Hemphill, NORO Hideo, Jarkko Hietaniemi, Scott Hofmann, Jeff Honig, -Dana Hudes, Eric Hughes, John Interrante, Ceriel Jacobs, Michal -Jaegermann, Sakari Jalovaara, Jeffrey R. Jones, Henry Juengst, Klaus -Kaempf, Jonathan I. Kamens, Terrence O Kane, Amir Katz, -`ken@ken.hilco.com', Kevin B. Kenny, Steve Kirsch, Winfried Koenig, -Marq Kole, Ronald Lamprecht, Greg Lee, Rohan Lenard, Craig Leres, John -Levine, Steve Liddle, Mike Long, Mohamed el Lozy, Brian Madsen, Malte, -Joe Marshall, Bengt Martensson, Chris Metcalf, Luke Mewburn, Jim -Meyering, R. Alexander Milowski, Erik Naggum, G.T. Nicol, Landon Noll, -James Nordby, Marc Nozell, Richard Ohnemus, Karsten Pahnke, Sven Panne, -Roland Pesch, Walter Pelissero, Gaumond Pierre, Esmond Pitt, Jef -Poskanzer, Joe Rahmeh, Jarmo Raiha, Frederic Raimbault, Pat Rankin, -Rick Richardson, Kevin Rodgers, Kai Uwe Rommel, Jim Roskind, Alberto -Santini, Andreas Scherer, Darrell Schiebel, Raf Schietekat, Doug -Schmidt, Philippe Schnoebelen, Andreas Schwab, Alex Siegel, Eckehard -Stolz, Jan-Erik Strvmquist, Mike Stump, Paul Stuart, Dave Tallman, Ian -Lance Taylor, Chris Thewalt, Richard M. Timoney, Jodi Tsai, Paul -Tuinenga, Gary Weik, Frank Whaley, Gerhard Wilhelms, Kent Williams, Ken -Yap, Ron Zellar, Nathan Zelle, David Zuhn, and those whose names have -slipped my marginal mail-archiving skills but whose contributions are -appreciated all the same. - - Thanks to Keith Bostic, Jon Forrest, Noah Friedman, John Gilmore, -Craig Leres, John Levine, Bob Mulcahy, G.T. Nicol, Francois Pinard, -Rich Salz, and Richard Stallman for help with various distribution -headaches. - - Thanks to Esmond Pitt and Earle Horton for 8-bit character support; -to Benson Margulies and Fred Burke for C++ support; to Kent Williams -and Tom Epperly for C++ class support; to Ove Ewerlid for support of -NUL's; and to Eric Hughes for support of multiple buffers. - - This work was primarily done when I was with the Real Time Systems -Group at the Lawrence Berkeley Laboratory in Berkeley, CA. Many thanks -to all there for the support I received. - - Send comments to `vern@ee.lbl.gov'. - - - -Tag Table: -Node: Top1430 -Node: Name2808 -Node: Synopsis2933 -Node: Overview3145 -Node: Description4986 -Node: Examples5748 -Node: Format8896 -Node: Patterns11637 -Node: Matching18138 -Node: Actions21438 -Node: Generated scanner30560 -Node: Start conditions34988 -Node: Multiple buffers45069 -Node: End-of-file rules50975 -Node: Miscellaneous52508 -Node: User variables55279 -Node: YACC interface57651 -Node: Options58542 -Node: Performance78234 -Node: C++87532 -Node: Incompatibilities94993 -Node: Diagnostics101853 -Node: Files105094 -Node: Deficiencies105715 -Node: See also107684 -Node: Author108216 - -End Tag Table diff --git a/commands/flex-2.5.4/MISC/texinfo/flex.texi b/commands/flex-2.5.4/MISC/texinfo/flex.texi deleted file mode 100644 index 23280b114..000000000 --- a/commands/flex-2.5.4/MISC/texinfo/flex.texi +++ /dev/null @@ -1,3448 +0,0 @@ -\input texinfo -@c %**start of header -@setfilename flex.info -@settitle Flex - a scanner generator -@c @finalout -@c @setchapternewpage odd -@c %**end of header - -@set EDITION 2.5 -@set UPDATED March 1995 -@set VERSION 2.5 - -@c FIXME - Reread a printed copy with a red pen and patience. -@c FIXME - Modify all "See ..." references and replace with @xref's. - -@ifinfo -@format -START-INFO-DIR-ENTRY -* Flex: (flex). A fast scanner generator. -END-INFO-DIR-ENTRY -@end format -@end ifinfo - -@c Define new indices for commands, filenames, and options. -@c @defcodeindex cm -@c @defcodeindex fl -@c @defcodeindex op - -@c Put everything in one index (arbitrarily chosen to be the concept index). -@c @syncodeindex cm cp -@c @syncodeindex fl cp -@syncodeindex fn cp -@syncodeindex ky cp -@c @syncodeindex op cp -@syncodeindex pg cp -@syncodeindex vr cp - -@ifinfo -This file documents Flex. - -Copyright (c) 1990 The Regents of the University of California. -All rights reserved. - -This code is derived from software contributed to Berkeley by -Vern Paxson. - -The United States Government has rights in this work pursuant -to contract no. DE-AC03-76SF00098 between the United States -Department of Energy and the University of California. - -Redistribution and use in source and binary forms with or without -modification are permitted provided that: (1) source distributions -retain this entire copyright notice and comment, and (2) -distributions including binaries display the following -acknowledgement: ``This product includes software developed by the -University of California, Berkeley and its contributors'' in the -documentation or other materials provided with the distribution and -in all advertising materials mentioning features or use of this -software. Neither the name of the University nor the names of its -contributors may be used to endorse or promote products derived -from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. - -@ignore -Permission is granted to process this file through TeX and print the -results, provided the printed document carries copying permission -notice identical to this one except for the removal of this paragraph -(this paragraph not being relevant to the printed manual). - -@end ignore -@end ifinfo - -@titlepage -@title Flex, version @value{VERSION} -@subtitle A fast scanner generator -@subtitle Edition @value{EDITION}, @value{UPDATED} -@author Vern Paxson - -@page -@vskip 0pt plus 1filll -Copyright @copyright{} 1990 The Regents of the University of California. -All rights reserved. - -This code is derived from software contributed to Berkeley by -Vern Paxson. - -The United States Government has rights in this work pursuant -to contract no. DE-AC03-76SF00098 between the United States -Department of Energy and the University of California. - -Redistribution and use in source and binary forms with or without -modification are permitted provided that: (1) source distributions -retain this entire copyright notice and comment, and (2) -distributions including binaries display the following -acknowledgement: ``This product includes software developed by the -University of California, Berkeley and its contributors'' in the -documentation or other materials provided with the distribution and -in all advertising materials mentioning features or use of this -software. Neither the name of the University nor the names of its -contributors may be used to endorse or promote products derived -from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. -@end titlepage - -@ifinfo - -@node Top, Name, (dir), (dir) -@top flex - -@cindex scanner generator - -This manual documents @code{flex}. It covers release @value{VERSION}. - -@menu -* Name:: Name -* Synopsis:: Synopsis -* Overview:: Overview -* Description:: Description -* Examples:: Some simple examples -* Format:: Format of the input file -* Patterns:: Patterns -* Matching:: How the input is matched -* Actions:: Actions -* Generated scanner:: The generated scanner -* Start conditions:: Start conditions -* Multiple buffers:: Multiple input buffers -* End-of-file rules:: End-of-file rules -* Miscellaneous:: Miscellaneous macros -* User variables:: Values available to the user -* YACC interface:: Interfacing with @code{yacc} -* Options:: Options -* Performance:: Performance considerations -* C++:: Generating C++ scanners -* Incompatibilities:: Incompatibilities with @code{lex} and POSIX -* Diagnostics:: Diagnostics -* Files:: Files -* Deficiencies:: Deficiencies / Bugs -* See also:: See also -* Author:: Author -@c * Index:: Index -@end menu - -@end ifinfo - -@node Name, Synopsis, Top, Top -@section Name - -flex - fast lexical analyzer generator - -@node Synopsis, Overview, Name, Top -@section Synopsis - -@example -flex [-bcdfhilnpstvwBFILTV78+? -C[aefFmr] -ooutput -Pprefix -Sskeleton] -[--help --version] [@var{filename} @dots{}] -@end example - -@node Overview, Description, Synopsis, Top -@section Overview - -This manual describes @code{flex}, a tool for generating programs -that perform pattern-matching on text. The manual -includes both tutorial and reference sections: - -@table @asis -@item Description -a brief overview of the tool - -@item Some Simple Examples - -@item Format Of The Input File - -@item Patterns -the extended regular expressions used by flex - -@item How The Input Is Matched -the rules for determining what has been matched - -@item Actions -how to specify what to do when a pattern is matched - -@item The Generated Scanner -details regarding the scanner that flex produces; -how to control the input source - -@item Start Conditions -introducing context into your scanners, and -managing "mini-scanners" - -@item Multiple Input Buffers -how to manipulate multiple input sources; how to -scan from strings instead of files - -@item End-of-file Rules -special rules for matching the end of the input - -@item Miscellaneous Macros -a summary of macros available to the actions - -@item Values Available To The User -a summary of values available to the actions - -@item Interfacing With Yacc -connecting flex scanners together with yacc parsers - -@item Options -flex command-line options, and the "%option" -directive - -@item Performance Considerations -how to make your scanner go as fast as possible - -@item Generating C++ Scanners -the (experimental) facility for generating C++ -scanner classes - -@item Incompatibilities With Lex And POSIX -how flex differs from AT&T lex and the POSIX lex -standard - -@item Diagnostics -those error messages produced by flex (or scanners -it generates) whose meanings might not be apparent - -@item Files -files used by flex - -@item Deficiencies / Bugs -known problems with flex - -@item See Also -other documentation, related tools - -@item Author -includes contact information -@end table - -@node Description, Examples, Overview, Top -@section Description - -@code{flex} is a tool for generating @dfn{scanners}: programs which -recognized lexical patterns in text. @code{flex} reads the given -input files, or its standard input if no file names are -given, for a description of a scanner to generate. The -description is in the form of pairs of regular expressions -and C code, called @dfn{rules}. @code{flex} generates as output a C -source file, @file{lex.yy.c}, which defines a routine @samp{yylex()}. -This file is compiled and linked with the @samp{-lfl} library to -produce an executable. When the executable is run, it -analyzes its input for occurrences of the regular -expressions. Whenever it finds one, it executes the -corresponding C code. - -@node Examples, Format, Description, Top -@section Some simple examples - -First some simple examples to get the flavor of how one -uses @code{flex}. The following @code{flex} input specifies a scanner -which whenever it encounters the string "username" will -replace it with the user's login name: - -@example -%% -username printf( "%s", getlogin() ); -@end example - -By default, any text not matched by a @code{flex} scanner is -copied to the output, so the net effect of this scanner is -to copy its input file to its output with each occurrence -of "username" expanded. In this input, there is just one -rule. "username" is the @var{pattern} and the "printf" is the -@var{action}. The "%%" marks the beginning of the rules. - -Here's another simple example: - -@example - int num_lines = 0, num_chars = 0; - -%% -\n ++num_lines; ++num_chars; -. ++num_chars; - -%% -main() - @{ - yylex(); - printf( "# of lines = %d, # of chars = %d\n", - num_lines, num_chars ); - @} -@end example - -This scanner counts the number of characters and the -number of lines in its input (it produces no output other -than the final report on the counts). The first line -declares two globals, "num_lines" and "num_chars", which -are accessible both inside @samp{yylex()} and in the @samp{main()} -routine declared after the second "%%". There are two rules, -one which matches a newline ("\n") and increments both the -line count and the character count, and one which matches -any character other than a newline (indicated by the "." -regular expression). - -A somewhat more complicated example: - -@example -/* scanner for a toy Pascal-like language */ - -%@{ -/* need this for the call to atof() below */ -#include -%@} - -DIGIT [0-9] -ID [a-z][a-z0-9]* - -%% - -@{DIGIT@}+ @{ - printf( "An integer: %s (%d)\n", yytext, - atoi( yytext ) ); - @} - -@{DIGIT@}+"."@{DIGIT@}* @{ - printf( "A float: %s (%g)\n", yytext, - atof( yytext ) ); - @} - -if|then|begin|end|procedure|function @{ - printf( "A keyword: %s\n", yytext ); - @} - -@{ID@} printf( "An identifier: %s\n", yytext ); - -"+"|"-"|"*"|"/" printf( "An operator: %s\n", yytext ); - -"@{"[^@}\n]*"@}" /* eat up one-line comments */ - -[ \t\n]+ /* eat up whitespace */ - -. printf( "Unrecognized character: %s\n", yytext ); - -%% - -main( argc, argv ) -int argc; -char **argv; - @{ - ++argv, --argc; /* skip over program name */ - if ( argc > 0 ) - yyin = fopen( argv[0], "r" ); - else - yyin = stdin; - - yylex(); - @} -@end example - -This is the beginnings of a simple scanner for a language -like Pascal. It identifies different types of @var{tokens} and -reports on what it has seen. - -The details of this example will be explained in the -following sections. - -@node Format, Patterns, Examples, Top -@section Format of the input file - -The @code{flex} input file consists of three sections, separated -by a line with just @samp{%%} in it: - -@example -definitions -%% -rules -%% -user code -@end example - -The @dfn{definitions} section contains declarations of simple -@dfn{name} definitions to simplify the scanner specification, -and declarations of @dfn{start conditions}, which are explained -in a later section. -Name definitions have the form: - -@example -name definition -@end example - -The "name" is a word beginning with a letter or an -underscore ('_') followed by zero or more letters, digits, '_', -or '-' (dash). The definition is taken to begin at the -first non-white-space character following the name and -continuing to the end of the line. The definition can -subsequently be referred to using "@{name@}", which will -expand to "(definition)". For example, - -@example -DIGIT [0-9] -ID [a-z][a-z0-9]* -@end example - -@noindent -defines "DIGIT" to be a regular expression which matches a -single digit, and "ID" to be a regular expression which -matches a letter followed by zero-or-more -letters-or-digits. A subsequent reference to - -@example -@{DIGIT@}+"."@{DIGIT@}* -@end example - -@noindent -is identical to - -@example -([0-9])+"."([0-9])* -@end example - -@noindent -and matches one-or-more digits followed by a '.' followed -by zero-or-more digits. - -The @var{rules} section of the @code{flex} input contains a series of -rules of the form: - -@example -pattern action -@end example - -@noindent -where the pattern must be unindented and the action must -begin on the same line. - -See below for a further description of patterns and -actions. - -Finally, the user code section is simply copied to -@file{lex.yy.c} verbatim. It is used for companion routines -which call or are called by the scanner. The presence of -this section is optional; if it is missing, the second @samp{%%} -in the input file may be skipped, too. - -In the definitions and rules sections, any @emph{indented} text or -text enclosed in @samp{%@{} and @samp{%@}} is copied verbatim to the -output (with the @samp{%@{@}}'s removed). The @samp{%@{@}}'s must -appear unindented on lines by themselves. - -In the rules section, any indented or %@{@} text appearing -before the first rule may be used to declare variables -which are local to the scanning routine and (after the -declarations) code which is to be executed whenever the -scanning routine is entered. Other indented or %@{@} text -in the rule section is still copied to the output, but its -meaning is not well-defined and it may well cause -compile-time errors (this feature is present for @code{POSIX} compliance; -see below for other such features). - -In the definitions section (but not in the rules section), -an unindented comment (i.e., a line beginning with "/*") -is also copied verbatim to the output up to the next "*/". - -@node Patterns, Matching, Format, Top -@section Patterns - -The patterns in the input are written using an extended -set of regular expressions. These are: - -@table @samp -@item x -match the character @samp{x} -@item . -any character (byte) except newline -@item [xyz] -a "character class"; in this case, the pattern -matches either an @samp{x}, a @samp{y}, or a @samp{z} -@item [abj-oZ] -a "character class" with a range in it; matches -an @samp{a}, a @samp{b}, any letter from @samp{j} through @samp{o}, -or a @samp{Z} -@item [^A-Z] -a "negated character class", i.e., any character -but those in the class. In this case, any -character EXCEPT an uppercase letter. -@item [^A-Z\n] -any character EXCEPT an uppercase letter or -a newline -@item @var{r}* -zero or more @var{r}'s, where @var{r} is any regular expression -@item @var{r}+ -one or more @var{r}'s -@item @var{r}? -zero or one @var{r}'s (that is, "an optional @var{r}") -@item @var{r}@{2,5@} -anywhere from two to five @var{r}'s -@item @var{r}@{2,@} -two or more @var{r}'s -@item @var{r}@{4@} -exactly 4 @var{r}'s -@item @{@var{name}@} -the expansion of the "@var{name}" definition -(see above) -@item "[xyz]\"foo" -the literal string: @samp{[xyz]"foo} -@item \@var{x} -if @var{x} is an @samp{a}, @samp{b}, @samp{f}, @samp{n}, @samp{r}, @samp{t}, or @samp{v}, -then the ANSI-C interpretation of \@var{x}. -Otherwise, a literal @samp{@var{x}} (used to escape -operators such as @samp{*}) -@item \0 -a NUL character (ASCII code 0) -@item \123 -the character with octal value 123 -@item \x2a -the character with hexadecimal value @code{2a} -@item (@var{r}) -match an @var{r}; parentheses are used to override -precedence (see below) -@item @var{r}@var{s} -the regular expression @var{r} followed by the -regular expression @var{s}; called "concatenation" -@item @var{r}|@var{s} -either an @var{r} or an @var{s} -@item @var{r}/@var{s} -an @var{r} but only if it is followed by an @var{s}. The text -matched by @var{s} is included when determining whether this rule is -the @dfn{longest match}, but is then returned to the input before -the action is executed. So the action only sees the text matched -by @var{r}. This type of pattern is called @dfn{trailing context}. -(There are some combinations of @samp{@var{r}/@var{s}} that @code{flex} -cannot match correctly; see notes in the Deficiencies / Bugs section -below regarding "dangerous trailing context".) -@item ^@var{r} -an @var{r}, but only at the beginning of a line (i.e., -which just starting to scan, or right after a -newline has been scanned). -@item @var{r}$ -an @var{r}, but only at the end of a line (i.e., just -before a newline). Equivalent to "@var{r}/\n". - -Note that flex's notion of "newline" is exactly -whatever the C compiler used to compile flex -interprets '\n' as; in particular, on some DOS -systems you must either filter out \r's in the -input yourself, or explicitly use @var{r}/\r\n for "r$". -@item <@var{s}>@var{r} -an @var{r}, but only in start condition @var{s} (see -below for discussion of start conditions) -<@var{s1},@var{s2},@var{s3}>@var{r} -same, but in any of start conditions @var{s1}, -@var{s2}, or @var{s3} -@item <*>@var{r} -an @var{r} in any start condition, even an exclusive one. -@item <> -an end-of-file -<@var{s1},@var{s2}><> -an end-of-file when in start condition @var{s1} or @var{s2} -@end table - -Note that inside of a character class, all regular -expression operators lose their special meaning except escape -('\') and the character class operators, '-', ']', and, at -the beginning of the class, '^'. - -The regular expressions listed above are grouped according -to precedence, from highest precedence at the top to -lowest at the bottom. Those grouped together have equal -precedence. For example, - -@example -foo|bar* -@end example - -@noindent -is the same as - -@example -(foo)|(ba(r*)) -@end example - -@noindent -since the '*' operator has higher precedence than -concatenation, and concatenation higher than alternation ('|'). -This pattern therefore matches @emph{either} the string "foo" @emph{or} -the string "ba" followed by zero-or-more r's. To match -"foo" or zero-or-more "bar"'s, use: - -@example -foo|(bar)* -@end example - -@noindent -and to match zero-or-more "foo"'s-or-"bar"'s: - -@example -(foo|bar)* -@end example - -In addition to characters and ranges of characters, -character classes can also contain character class -@dfn{expressions}. These are expressions enclosed inside @samp{[}: and @samp{:}] -delimiters (which themselves must appear between the '[' -and ']' of the character class; other elements may occur -inside the character class, too). The valid expressions -are: - -@example -[:alnum:] [:alpha:] [:blank:] -[:cntrl:] [:digit:] [:graph:] -[:lower:] [:print:] [:punct:] -[:space:] [:upper:] [:xdigit:] -@end example - -These expressions all designate a set of characters -equivalent to the corresponding standard C @samp{isXXX} function. For -example, @samp{[:alnum:]} designates those characters for which -@samp{isalnum()} returns true - i.e., any alphabetic or numeric. -Some systems don't provide @samp{isblank()}, so flex defines -@samp{[:blank:]} as a blank or a tab. - -For example, the following character classes are all -equivalent: - -@example -[[:alnum:]] -[[:alpha:][:digit:] -[[:alpha:]0-9] -[a-zA-Z0-9] -@end example - -If your scanner is case-insensitive (the @samp{-i} flag), then -@samp{[:upper:]} and @samp{[:lower:]} are equivalent to @samp{[:alpha:]}. - -Some notes on patterns: - -@itemize - -@item -A negated character class such as the example -"[^A-Z]" above @emph{will match a newline} unless "\n" (or an -equivalent escape sequence) is one of the -characters explicitly present in the negated character -class (e.g., "[^A-Z\n]"). This is unlike how many -other regular expression tools treat negated -character classes, but unfortunately the inconsistency -is historically entrenched. Matching newlines -means that a pattern like [^"]* can match the -entire input unless there's another quote in the -input. - -@item -A rule can have at most one instance of trailing -context (the '/' operator or the '$' operator). -The start condition, '^', and "<>" patterns -can only occur at the beginning of a pattern, and, -as well as with '/' and '$', cannot be grouped -inside parentheses. A '^' which does not occur at -the beginning of a rule or a '$' which does not -occur at the end of a rule loses its special -properties and is treated as a normal character. - -The following are illegal: - -@example -foo/bar$ -foobar -@end example - -Note that the first of these, can be written -"foo/bar\n". - -The following will result in '$' or '^' being -treated as a normal character: - -@example -foo|(bar$) -foo|^bar -@end example - -If what's wanted is a "foo" or a -bar-followed-by-a-newline, the following could be used (the special -'|' action is explained below): - -@example -foo | -bar$ /* action goes here */ -@end example - -A similar trick will work for matching a foo or a -bar-at-the-beginning-of-a-line. -@end itemize - -@node Matching, Actions, Patterns, Top -@section How the input is matched - -When the generated scanner is run, it analyzes its input -looking for strings which match any of its patterns. If -it finds more than one match, it takes the one matching -the most text (for trailing context rules, this includes -the length of the trailing part, even though it will then -be returned to the input). If it finds two or more -matches of the same length, the rule listed first in the -@code{flex} input file is chosen. - -Once the match is determined, the text corresponding to -the match (called the @var{token}) is made available in the -global character pointer @code{yytext}, and its length in the -global integer @code{yyleng}. The @var{action} corresponding to the -matched pattern is then executed (a more detailed -description of actions follows), and then the remaining input is -scanned for another match. - -If no match is found, then the @dfn{default rule} is executed: -the next character in the input is considered matched and -copied to the standard output. Thus, the simplest legal -@code{flex} input is: - -@example -%% -@end example - -which generates a scanner that simply copies its input -(one character at a time) to its output. - -Note that @code{yytext} can be defined in two different ways: -either as a character @emph{pointer} or as a character @emph{array}. -You can control which definition @code{flex} uses by including -one of the special directives @samp{%pointer} or @samp{%array} in the -first (definitions) section of your flex input. The -default is @samp{%pointer}, unless you use the @samp{-l} lex -compatibility option, in which case @code{yytext} will be an array. The -advantage of using @samp{%pointer} is substantially faster -scanning and no buffer overflow when matching very large -tokens (unless you run out of dynamic memory). The -disadvantage is that you are restricted in how your actions can -modify @code{yytext} (see the next section), and calls to the -@samp{unput()} function destroys the present contents of @code{yytext}, -which can be a considerable porting headache when moving -between different @code{lex} versions. - -The advantage of @samp{%array} is that you can then modify @code{yytext} -to your heart's content, and calls to @samp{unput()} do not -destroy @code{yytext} (see below). Furthermore, existing @code{lex} -programs sometimes access @code{yytext} externally using -declarations of the form: -@example -extern char yytext[]; -@end example -This definition is erroneous when used with @samp{%pointer}, but -correct for @samp{%array}. - -@samp{%array} defines @code{yytext} to be an array of @code{YYLMAX} characters, -which defaults to a fairly large value. You can change -the size by simply #define'ing @code{YYLMAX} to a different value -in the first section of your @code{flex} input. As mentioned -above, with @samp{%pointer} yytext grows dynamically to -accommodate large tokens. While this means your @samp{%pointer} scanner -can accommodate very large tokens (such as matching entire -blocks of comments), bear in mind that each time the -scanner must resize @code{yytext} it also must rescan the entire -token from the beginning, so matching such tokens can -prove slow. @code{yytext} presently does @emph{not} dynamically grow if -a call to @samp{unput()} results in too much text being pushed -back; instead, a run-time error results. - -Also note that you cannot use @samp{%array} with C++ scanner -classes (the @code{c++} option; see below). - -@node Actions, Generated scanner, Matching, Top -@section Actions - -Each pattern in a rule has a corresponding action, which -can be any arbitrary C statement. The pattern ends at the -first non-escaped whitespace character; the remainder of -the line is its action. If the action is empty, then when -the pattern is matched the input token is simply -discarded. For example, here is the specification for a -program which deletes all occurrences of "zap me" from its -input: - -@example -%% -"zap me" -@end example - -(It will copy all other characters in the input to the -output since they will be matched by the default rule.) - -Here is a program which compresses multiple blanks and -tabs down to a single blank, and throws away whitespace -found at the end of a line: - -@example -%% -[ \t]+ putchar( ' ' ); -[ \t]+$ /* ignore this token */ -@end example - -If the action contains a '@{', then the action spans till -the balancing '@}' is found, and the action may cross -multiple lines. @code{flex} knows about C strings and comments and -won't be fooled by braces found within them, but also -allows actions to begin with @samp{%@{} and will consider the -action to be all the text up to the next @samp{%@}} (regardless of -ordinary braces inside the action). - -An action consisting solely of a vertical bar ('|') means -"same as the action for the next rule." See below for an -illustration. - -Actions can include arbitrary C code, including @code{return} -statements to return a value to whatever routine called -@samp{yylex()}. Each time @samp{yylex()} is called it continues -processing tokens from where it last left off until it either -reaches the end of the file or executes a return. - -Actions are free to modify @code{yytext} except for lengthening -it (adding characters to its end--these will overwrite -later characters in the input stream). This however does -not apply when using @samp{%array} (see above); in that case, -@code{yytext} may be freely modified in any way. - -Actions are free to modify @code{yyleng} except they should not -do so if the action also includes use of @samp{yymore()} (see -below). - -There are a number of special directives which can be -included within an action: - -@itemize - -@item -@samp{ECHO} copies yytext to the scanner's output. - -@item -@code{BEGIN} followed by the name of a start condition -places the scanner in the corresponding start -condition (see below). - -@item -@code{REJECT} directs the scanner to proceed on to the -"second best" rule which matched the input (or a -prefix of the input). The rule is chosen as -described above in "How the Input is Matched", and -@code{yytext} and @code{yyleng} set up appropriately. It may -either be one which matched as much text as the -originally chosen rule but came later in the @code{flex} -input file, or one which matched less text. For -example, the following will both count the words in -the input and call the routine special() whenever -"frob" is seen: - -@example - int word_count = 0; -%% - -frob special(); REJECT; -[^ \t\n]+ ++word_count; -@end example - -Without the @code{REJECT}, any "frob"'s in the input would -not be counted as words, since the scanner normally -executes only one action per token. Multiple -@code{REJECT's} are allowed, each one finding the next -best choice to the currently active rule. For -example, when the following scanner scans the token -"abcd", it will write "abcdabcaba" to the output: - -@example -%% -a | -ab | -abc | -abcd ECHO; REJECT; -.|\n /* eat up any unmatched character */ -@end example - -(The first three rules share the fourth's action -since they use the special '|' action.) @code{REJECT} is -a particularly expensive feature in terms of -scanner performance; if it is used in @emph{any} of the -scanner's actions it will slow down @emph{all} of the -scanner's matching. Furthermore, @code{REJECT} cannot be used -with the @samp{-Cf} or @samp{-CF} options (see below). - -Note also that unlike the other special actions, -@code{REJECT} is a @emph{branch}; code immediately following it -in the action will @emph{not} be executed. - -@item -@samp{yymore()} tells the scanner that the next time it -matches a rule, the corresponding token should be -@emph{appended} onto the current value of @code{yytext} rather -than replacing it. For example, given the input -"mega-kludge" the following will write -"mega-mega-kludge" to the output: - -@example -%% -mega- ECHO; yymore(); -kludge ECHO; -@end example - -First "mega-" is matched and echoed to the output. -Then "kludge" is matched, but the previous "mega-" -is still hanging around at the beginning of @code{yytext} -so the @samp{ECHO} for the "kludge" rule will actually -write "mega-kludge". -@end itemize - -Two notes regarding use of @samp{yymore()}. First, @samp{yymore()} -depends on the value of @code{yyleng} correctly reflecting the -size of the current token, so you must not modify @code{yyleng} -if you are using @samp{yymore()}. Second, the presence of -@samp{yymore()} in the scanner's action entails a minor -performance penalty in the scanner's matching speed. - -@itemize - -@item -@samp{yyless(n)} returns all but the first @var{n} characters of -the current token back to the input stream, where -they will be rescanned when the scanner looks for -the next match. @code{yytext} and @code{yyleng} are adjusted -appropriately (e.g., @code{yyleng} will now be equal to @var{n} -). For example, on the input "foobar" the -following will write out "foobarbar": - -@example -%% -foobar ECHO; yyless(3); -[a-z]+ ECHO; -@end example - -An argument of 0 to @code{yyless} will cause the entire -current input string to be scanned again. Unless -you've changed how the scanner will subsequently -process its input (using @code{BEGIN}, for example), this -will result in an endless loop. - -Note that @code{yyless} is a macro and can only be used in the -flex input file, not from other source files. - -@item -@samp{unput(c)} puts the character @code{c} back onto the input -stream. It will be the next character scanned. -The following action will take the current token -and cause it to be rescanned enclosed in -parentheses. - -@example -@{ -int i; -/* Copy yytext because unput() trashes yytext */ -char *yycopy = strdup( yytext ); -unput( ')' ); -for ( i = yyleng - 1; i >= 0; --i ) - unput( yycopy[i] ); -unput( '(' ); -free( yycopy ); -@} -@end example - -Note that since each @samp{unput()} puts the given -character back at the @emph{beginning} of the input stream, -pushing back strings must be done back-to-front. -An important potential problem when using @samp{unput()} is that -if you are using @samp{%pointer} (the default), a call to @samp{unput()} -@emph{destroys} the contents of @code{yytext}, starting with its -rightmost character and devouring one character to the left -with each call. If you need the value of yytext preserved -after a call to @samp{unput()} (as in the above example), you -must either first copy it elsewhere, or build your scanner -using @samp{%array} instead (see How The Input Is Matched). - -Finally, note that you cannot put back @code{EOF} to attempt to -mark the input stream with an end-of-file. - -@item -@samp{input()} reads the next character from the input -stream. For example, the following is one way to -eat up C comments: - -@example -%% -"/*" @{ - register int c; - - for ( ; ; ) - @{ - while ( (c = input()) != '*' && - c != EOF ) - ; /* eat up text of comment */ - - if ( c == '*' ) - @{ - while ( (c = input()) == '*' ) - ; - if ( c == '/' ) - break; /* found the end */ - @} - - if ( c == EOF ) - @{ - error( "EOF in comment" ); - break; - @} - @} - @} -@end example - -(Note that if the scanner is compiled using @samp{C++}, -then @samp{input()} is instead referred to as @samp{yyinput()}, -in order to avoid a name clash with the @samp{C++} stream -by the name of @code{input}.) - -@item YY_FLUSH_BUFFER -flushes the scanner's internal buffer so that the next time the scanner -attempts to match a token, it will first refill the buffer using -@code{YY_INPUT} (see The Generated Scanner, below). This action is -a special case of the more general @samp{yy_flush_buffer()} function, -described below in the section Multiple Input Buffers. - -@item -@samp{yyterminate()} can be used in lieu of a return -statement in an action. It terminates the scanner -and returns a 0 to the scanner's caller, indicating -"all done". By default, @samp{yyterminate()} is also -called when an end-of-file is encountered. It is a -macro and may be redefined. -@end itemize - -@node Generated scanner, Start conditions, Actions, Top -@section The generated scanner - -The output of @code{flex} is the file @file{lex.yy.c}, which contains -the scanning routine @samp{yylex()}, a number of tables used by -it for matching tokens, and a number of auxiliary routines -and macros. By default, @samp{yylex()} is declared as follows: - -@example -int yylex() - @{ - @dots{} various definitions and the actions in here @dots{} - @} -@end example - -(If your environment supports function prototypes, then it -will be "int yylex( void )".) This definition may be -changed by defining the "YY_DECL" macro. For example, you -could use: - -@example -#define YY_DECL float lexscan( a, b ) float a, b; -@end example - -to give the scanning routine the name @code{lexscan}, returning a -float, and taking two floats as arguments. Note that if -you give arguments to the scanning routine using a -K&R-style/non-prototyped function declaration, you must -terminate the definition with a semi-colon (@samp{;}). - -Whenever @samp{yylex()} is called, it scans tokens from the -global input file @code{yyin} (which defaults to stdin). It -continues until it either reaches an end-of-file (at which -point it returns the value 0) or one of its actions -executes a @code{return} statement. - -If the scanner reaches an end-of-file, subsequent calls are undefined -unless either @code{yyin} is pointed at a new input file (in which case -scanning continues from that file), or @samp{yyrestart()} is called. -@samp{yyrestart()} takes one argument, a @samp{FILE *} pointer (which -can be nil, if you've set up @code{YY_INPUT} to scan from a source -other than @code{yyin}), and initializes @code{yyin} for scanning from -that file. Essentially there is no difference between just assigning -@code{yyin} to a new input file or using @samp{yyrestart()} to do so; -the latter is available for compatibility with previous versions of -@code{flex}, and because it can be used to switch input files in the -middle of scanning. It can also be used to throw away the current -input buffer, by calling it with an argument of @code{yyin}; but -better is to use @code{YY_FLUSH_BUFFER} (see above). Note that -@samp{yyrestart()} does @emph{not} reset the start condition to -@code{INITIAL} (see Start Conditions, below). - - -If @samp{yylex()} stops scanning due to executing a @code{return} -statement in one of the actions, the scanner may then be called -again and it will resume scanning where it left off. - -By default (and for purposes of efficiency), the scanner -uses block-reads rather than simple @samp{getc()} calls to read -characters from @code{yyin}. The nature of how it gets its input -can be controlled by defining the @code{YY_INPUT} macro. -YY_INPUT's calling sequence is -"YY_INPUT(buf,result,max_size)". Its action is to place -up to @var{max_size} characters in the character array @var{buf} and -return in the integer variable @var{result} either the number of -characters read or the constant YY_NULL (0 on Unix -systems) to indicate EOF. The default YY_INPUT reads from -the global file-pointer "yyin". - -A sample definition of YY_INPUT (in the definitions -section of the input file): - -@example -%@{ -#define YY_INPUT(buf,result,max_size) \ - @{ \ - int c = getchar(); \ - result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \ - @} -%@} -@end example - -This definition will change the input processing to occur -one character at a time. - -When the scanner receives an end-of-file indication from -YY_INPUT, it then checks the @samp{yywrap()} function. If -@samp{yywrap()} returns false (zero), then it is assumed that the -function has gone ahead and set up @code{yyin} to point to -another input file, and scanning continues. If it returns -true (non-zero), then the scanner terminates, returning 0 -to its caller. Note that in either case, the start -condition remains unchanged; it does @emph{not} revert to @code{INITIAL}. - -If you do not supply your own version of @samp{yywrap()}, then you -must either use @samp{%option noyywrap} (in which case the scanner -behaves as though @samp{yywrap()} returned 1), or you must link with -@samp{-lfl} to obtain the default version of the routine, which always -returns 1. - -Three routines are available for scanning from in-memory -buffers rather than files: @samp{yy_scan_string()}, -@samp{yy_scan_bytes()}, and @samp{yy_scan_buffer()}. See the discussion -of them below in the section Multiple Input Buffers. - -The scanner writes its @samp{ECHO} output to the @code{yyout} global -(default, stdout), which may be redefined by the user -simply by assigning it to some other @code{FILE} pointer. - -@node Start conditions, Multiple buffers, Generated scanner, Top -@section Start conditions - -@code{flex} provides a mechanism for conditionally activating -rules. Any rule whose pattern is prefixed with "" -will only be active when the scanner is in the start -condition named "sc". For example, - -@example -[^"]* @{ /* eat up the string body ... */ - @dots{} - @} -@end example - -@noindent -will be active only when the scanner is in the "STRING" -start condition, and - -@example -\. @{ /* handle an escape ... */ - @dots{} - @} -@end example - -@noindent -will be active only when the current start condition is -either "INITIAL", "STRING", or "QUOTE". - -Start conditions are declared in the definitions (first) -section of the input using unindented lines beginning with -either @samp{%s} or @samp{%x} followed by a list of names. The former -declares @emph{inclusive} start conditions, the latter @emph{exclusive} -start conditions. A start condition is activated using -the @code{BEGIN} action. Until the next @code{BEGIN} action is -executed, rules with the given start condition will be active -and rules with other start conditions will be inactive. -If the start condition is @emph{inclusive}, then rules with no -start conditions at all will also be active. If it is -@emph{exclusive}, then @emph{only} rules qualified with the start -condition will be active. A set of rules contingent on the -same exclusive start condition describe a scanner which is -independent of any of the other rules in the @code{flex} input. -Because of this, exclusive start conditions make it easy -to specify "mini-scanners" which scan portions of the -input that are syntactically different from the rest -(e.g., comments). - -If the distinction between inclusive and exclusive start -conditions is still a little vague, here's a simple -example illustrating the connection between the two. The set -of rules: - -@example -%s example -%% - -foo do_something(); - -bar something_else(); -@end example - -@noindent -is equivalent to - -@example -%x example -%% - -foo do_something(); - -bar something_else(); -@end example - -Without the @samp{} qualifier, the @samp{bar} pattern -in the second example wouldn't be active (i.e., couldn't match) when -in start condition @samp{example}. If we just used @samp{} -to qualify @samp{bar}, though, then it would only be active in -@samp{example} and not in @code{INITIAL}, while in the first example -it's active in both, because in the first example the @samp{example} -starting condition is an @emph{inclusive} (@samp{%s}) start condition. - -Also note that the special start-condition specifier @samp{<*>} -matches every start condition. Thus, the above example -could also have been written; - -@example -%x example -%% - -foo do_something(); - -<*>bar something_else(); -@end example - -The default rule (to @samp{ECHO} any unmatched character) remains -active in start conditions. It is equivalent to: - -@example -<*>.|\\n ECHO; -@end example - -@samp{BEGIN(0)} returns to the original state where only the -rules with no start conditions are active. This state can -also be referred to as the start-condition "INITIAL", so -@samp{BEGIN(INITIAL)} is equivalent to @samp{BEGIN(0)}. (The -parentheses around the start condition name are not required but -are considered good style.) - -@code{BEGIN} actions can also be given as indented code at the -beginning of the rules section. For example, the -following will cause the scanner to enter the "SPECIAL" start -condition whenever @samp{yylex()} is called and the global -variable @code{enter_special} is true: - -@example - int enter_special; - -%x SPECIAL -%% - if ( enter_special ) - BEGIN(SPECIAL); - -blahblahblah -@dots{}more rules follow@dots{} -@end example - -To illustrate the uses of start conditions, here is a -scanner which provides two different interpretations of a -string like "123.456". By default it will treat it as as -three tokens, the integer "123", a dot ('.'), and the -integer "456". But if the string is preceded earlier in -the line by the string "expect-floats" it will treat it as -a single token, the floating-point number 123.456: - -@example -%@{ -#include -%@} -%s expect - -%% -expect-floats BEGIN(expect); - -[0-9]+"."[0-9]+ @{ - printf( "found a float, = %f\n", - atof( yytext ) ); - @} -\n @{ - /* that's the end of the line, so - * we need another "expect-number" - * before we'll recognize any more - * numbers - */ - BEGIN(INITIAL); - @} - -[0-9]+ @{ - -Version 2.5 December 1994 18 - - printf( "found an integer, = %d\n", - atoi( yytext ) ); - @} - -"." printf( "found a dot\n" ); -@end example - -Here is a scanner which recognizes (and discards) C -comments while maintaining a count of the current input line. - -@example -%x comment -%% - int line_num = 1; - -"/*" BEGIN(comment); - -[^*\n]* /* eat anything that's not a '*' */ -"*"+[^*/\n]* /* eat up '*'s not followed by '/'s */ -\n ++line_num; -"*"+"/" BEGIN(INITIAL); -@end example - -This scanner goes to a bit of trouble to match as much -text as possible with each rule. In general, when -attempting to write a high-speed scanner try to match as -much possible in each rule, as it's a big win. - -Note that start-conditions names are really integer values -and can be stored as such. Thus, the above could be -extended in the following fashion: - -@example -%x comment foo -%% - int line_num = 1; - int comment_caller; - -"/*" @{ - comment_caller = INITIAL; - BEGIN(comment); - @} - -@dots{} - -"/*" @{ - comment_caller = foo; - BEGIN(comment); - @} - -[^*\n]* /* eat anything that's not a '*' */ -"*"+[^*/\n]* /* eat up '*'s not followed by '/'s */ -\n ++line_num; -"*"+"/" BEGIN(comment_caller); -@end example - -Furthermore, you can access the current start condition -using the integer-valued @code{YY_START} macro. For example, the -above assignments to @code{comment_caller} could instead be -written - -@example -comment_caller = YY_START; -@end example - -Flex provides @code{YYSTATE} as an alias for @code{YY_START} (since that -is what's used by AT&T @code{lex}). - -Note that start conditions do not have their own -name-space; %s's and %x's declare names in the same fashion as -#define's. - -Finally, here's an example of how to match C-style quoted -strings using exclusive start conditions, including -expanded escape sequences (but not including checking for -a string that's too long): - -@example -%x str - -%% - char string_buf[MAX_STR_CONST]; - char *string_buf_ptr; - -\" string_buf_ptr = string_buf; BEGIN(str); - -\" @{ /* saw closing quote - all done */ - BEGIN(INITIAL); - *string_buf_ptr = '\0'; - /* return string constant token type and - * value to parser - */ - @} - -\n @{ - /* error - unterminated string constant */ - /* generate error message */ - @} - -\\[0-7]@{1,3@} @{ - /* octal escape sequence */ - int result; - - (void) sscanf( yytext + 1, "%o", &result ); - - if ( result > 0xff ) - /* error, constant is out-of-bounds */ - - *string_buf_ptr++ = result; - @} - -\\[0-9]+ @{ - /* generate error - bad escape sequence; something - * like '\48' or '\0777777' - */ - @} - -\\n *string_buf_ptr++ = '\n'; -\\t *string_buf_ptr++ = '\t'; -\\r *string_buf_ptr++ = '\r'; -\\b *string_buf_ptr++ = '\b'; -\\f *string_buf_ptr++ = '\f'; - -\\(.|\n) *string_buf_ptr++ = yytext[1]; - -[^\\\n\"]+ @{ - char *yptr = yytext; - - while ( *yptr ) - *string_buf_ptr++ = *yptr++; - @} -@end example - -Often, such as in some of the examples above, you wind up -writing a whole bunch of rules all preceded by the same -start condition(s). Flex makes this a little easier and -cleaner by introducing a notion of start condition @dfn{scope}. -A start condition scope is begun with: - -@example -@{ -@end example - -@noindent -where SCs is a list of one or more start conditions. -Inside the start condition scope, every rule automatically -has the prefix @samp{} applied to it, until a @samp{@}} which -matches the initial @samp{@{}. So, for example, - -@example -@{ - "\\n" return '\n'; - "\\r" return '\r'; - "\\f" return '\f'; - "\\0" return '\0'; -@} -@end example - -@noindent -is equivalent to: - -@example -"\\n" return '\n'; -"\\r" return '\r'; -"\\f" return '\f'; -"\\0" return '\0'; -@end example - -Start condition scopes may be nested. - -Three routines are available for manipulating stacks of -start conditions: - -@table @samp -@item void yy_push_state(int new_state) -pushes the current start condition onto the top of -the start condition stack and switches to @var{new_state} -as though you had used @samp{BEGIN new_state} (recall that -start condition names are also integers). - -@item void yy_pop_state() -pops the top of the stack and switches to it via -@code{BEGIN}. - -@item int yy_top_state() -returns the top of the stack without altering the -stack's contents. -@end table - -The start condition stack grows dynamically and so has no -built-in size limitation. If memory is exhausted, program -execution aborts. - -To use start condition stacks, your scanner must include a -@samp{%option stack} directive (see Options below). - -@node Multiple buffers, End-of-file rules, Start conditions, Top -@section Multiple input buffers - -Some scanners (such as those which support "include" -files) require reading from several input streams. As -@code{flex} scanners do a large amount of buffering, one cannot -control where the next input will be read from by simply -writing a @code{YY_INPUT} which is sensitive to the scanning -context. @code{YY_INPUT} is only called when the scanner reaches -the end of its buffer, which may be a long time after -scanning a statement such as an "include" which requires -switching the input source. - -To negotiate these sorts of problems, @code{flex} provides a -mechanism for creating and switching between multiple -input buffers. An input buffer is created by using: - -@example -YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) -@end example - -@noindent -which takes a @code{FILE} pointer and a size and creates a buffer -associated with the given file and large enough to hold -@var{size} characters (when in doubt, use @code{YY_BUF_SIZE} for the -size). It returns a @code{YY_BUFFER_STATE} handle, which may -then be passed to other routines (see below). The -@code{YY_BUFFER_STATE} type is a pointer to an opaque @code{struct} -@code{yy_buffer_state} structure, so you may safely initialize -YY_BUFFER_STATE variables to @samp{((YY_BUFFER_STATE) 0)} if you -wish, and also refer to the opaque structure in order to -correctly declare input buffers in source files other than -that of your scanner. Note that the @code{FILE} pointer in the -call to @code{yy_create_buffer} is only used as the value of @code{yyin} -seen by @code{YY_INPUT}; if you redefine @code{YY_INPUT} so it no longer -uses @code{yyin}, then you can safely pass a nil @code{FILE} pointer to -@code{yy_create_buffer}. You select a particular buffer to scan -from using: - -@example -void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) -@end example - -switches the scanner's input buffer so subsequent tokens -will come from @var{new_buffer}. Note that -@samp{yy_switch_to_buffer()} may be used by @samp{yywrap()} to set -things up for continued scanning, instead of opening a new -file and pointing @code{yyin} at it. Note also that switching -input sources via either @samp{yy_switch_to_buffer()} or @samp{yywrap()} -does @emph{not} change the start condition. - -@example -void yy_delete_buffer( YY_BUFFER_STATE buffer ) -@end example - -@noindent -is used to reclaim the storage associated with a buffer. -You can also clear the current contents of a buffer using: - -@example -void yy_flush_buffer( YY_BUFFER_STATE buffer ) -@end example - -This function discards the buffer's contents, so the next time the -scanner attempts to match a token from the buffer, it will first fill -the buffer anew using @code{YY_INPUT}. - -@samp{yy_new_buffer()} is an alias for @samp{yy_create_buffer()}, -provided for compatibility with the C++ use of @code{new} and @code{delete} -for creating and destroying dynamic objects. - -Finally, the @code{YY_CURRENT_BUFFER} macro returns a -@code{YY_BUFFER_STATE} handle to the current buffer. - -Here is an example of using these features for writing a -scanner which expands include files (the @samp{<>} feature -is discussed below): - -@example -/* the "incl" state is used for picking up the name - * of an include file - */ -%x incl - -%@{ -#define MAX_INCLUDE_DEPTH 10 -YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH]; -int include_stack_ptr = 0; -%@} - -%% -include BEGIN(incl); - -[a-z]+ ECHO; -[^a-z\n]*\n? ECHO; - -[ \t]* /* eat the whitespace */ -[^ \t\n]+ @{ /* got the include file name */ - if ( include_stack_ptr >= MAX_INCLUDE_DEPTH ) - @{ - fprintf( stderr, "Includes nested too deeply" ); - exit( 1 ); - @} - - include_stack[include_stack_ptr++] = - YY_CURRENT_BUFFER; - - yyin = fopen( yytext, "r" ); - - if ( ! yyin ) - error( @dots{} ); - - yy_switch_to_buffer( - yy_create_buffer( yyin, YY_BUF_SIZE ) ); - - BEGIN(INITIAL); - @} - -<> @{ - if ( --include_stack_ptr < 0 ) - @{ - yyterminate(); - @} - - else - @{ - yy_delete_buffer( YY_CURRENT_BUFFER ); - yy_switch_to_buffer( - include_stack[include_stack_ptr] ); - @} - @} -@end example - -Three routines are available for setting up input buffers -for scanning in-memory strings instead of files. All of -them create a new input buffer for scanning the string, -and return a corresponding @code{YY_BUFFER_STATE} handle (which -you should delete with @samp{yy_delete_buffer()} when done with -it). They also switch to the new buffer using -@samp{yy_switch_to_buffer()}, so the next call to @samp{yylex()} will -start scanning the string. - -@table @samp -@item yy_scan_string(const char *str) -scans a NUL-terminated string. - -@item yy_scan_bytes(const char *bytes, int len) -scans @code{len} bytes (including possibly NUL's) starting -at location @var{bytes}. -@end table - -Note that both of these functions create and scan a @emph{copy} -of the string or bytes. (This may be desirable, since -@samp{yylex()} modifies the contents of the buffer it is -scanning.) You can avoid the copy by using: - -@table @samp -@item yy_scan_buffer(char *base, yy_size_t size) -which scans in place the buffer starting at @var{base}, -consisting of @var{size} bytes, the last two bytes of -which @emph{must} be @code{YY_END_OF_BUFFER_CHAR} (ASCII NUL). -These last two bytes are not scanned; thus, -scanning consists of @samp{base[0]} through @samp{base[size-2]}, -inclusive. - -If you fail to set up @var{base} in this manner (i.e., -forget the final two @code{YY_END_OF_BUFFER_CHAR} bytes), -then @samp{yy_scan_buffer()} returns a nil pointer instead -of creating a new input buffer. - -The type @code{yy_size_t} is an integral type to which you -can cast an integer expression reflecting the size -of the buffer. -@end table - -@node End-of-file rules, Miscellaneous, Multiple buffers, Top -@section End-of-file rules - -The special rule "<>" indicates actions which are to -be taken when an end-of-file is encountered and yywrap() -returns non-zero (i.e., indicates no further files to -process). The action must finish by doing one of four -things: - -@itemize - -@item -assigning @code{yyin} to a new input file (in previous -versions of flex, after doing the assignment you -had to call the special action @code{YY_NEW_FILE}; this is -no longer necessary); - -@item -executing a @code{return} statement; - -@item -executing the special @samp{yyterminate()} action; - -@item -or, switching to a new buffer using -@samp{yy_switch_to_buffer()} as shown in the example -above. -@end itemize - -<> rules may not be used with other patterns; they -may only be qualified with a list of start conditions. If -an unqualified <> rule is given, it applies to @emph{all} -start conditions which do not already have <> -actions. To specify an <> rule for only the initial -start condition, use - -@example -<> -@end example - -These rules are useful for catching things like unclosed -comments. An example: - -@example -%x quote -%% - -@dots{}other rules for dealing with quotes@dots{} - -<> @{ - error( "unterminated quote" ); - yyterminate(); - @} -<> @{ - if ( *++filelist ) - yyin = fopen( *filelist, "r" ); - else - yyterminate(); - @} -@end example - -@node Miscellaneous, User variables, End-of-file rules, Top -@section Miscellaneous macros - -The macro @code{YY_USER_ACTION} can be defined to provide an -action which is always executed prior to the matched -rule's action. For example, it could be #define'd to call -a routine to convert yytext to lower-case. When -@code{YY_USER_ACTION} is invoked, the variable @code{yy_act} gives the -number of the matched rule (rules are numbered starting -with 1). Suppose you want to profile how often each of -your rules is matched. The following would do the trick: - -@example -#define YY_USER_ACTION ++ctr[yy_act] -@end example - -where @code{ctr} is an array to hold the counts for the different -rules. Note that the macro @code{YY_NUM_RULES} gives the total number -of rules (including the default rule, even if you use @samp{-s}, so -a correct declaration for @code{ctr} is: - -@example -int ctr[YY_NUM_RULES]; -@end example - -The macro @code{YY_USER_INIT} may be defined to provide an action -which is always executed before the first scan (and before -the scanner's internal initializations are done). For -example, it could be used to call a routine to read in a -data table or open a logging file. - -The macro @samp{yy_set_interactive(is_interactive)} can be used -to control whether the current buffer is considered -@emph{interactive}. An interactive buffer is processed more slowly, -but must be used when the scanner's input source is indeed -interactive to avoid problems due to waiting to fill -buffers (see the discussion of the @samp{-I} flag below). A -non-zero value in the macro invocation marks the buffer as -interactive, a zero value as non-interactive. Note that -use of this macro overrides @samp{%option always-interactive} or -@samp{%option never-interactive} (see Options below). -@samp{yy_set_interactive()} must be invoked prior to beginning to -scan the buffer that is (or is not) to be considered -interactive. - -The macro @samp{yy_set_bol(at_bol)} can be used to control -whether the current buffer's scanning context for the next -token match is done as though at the beginning of a line. -A non-zero macro argument makes rules anchored with - -The macro @samp{YY_AT_BOL()} returns true if the next token -scanned from the current buffer will have '^' rules -active, false otherwise. - -In the generated scanner, the actions are all gathered in -one large switch statement and separated using @code{YY_BREAK}, -which may be redefined. By default, it is simply a -"break", to separate each rule's action from the following -rule's. Redefining @code{YY_BREAK} allows, for example, C++ -users to #define YY_BREAK to do nothing (while being very -careful that every rule ends with a "break" or a -"return"!) to avoid suffering from unreachable statement -warnings where because a rule's action ends with "return", -the @code{YY_BREAK} is inaccessible. - -@node User variables, YACC interface, Miscellaneous, Top -@section Values available to the user - -This section summarizes the various values available to -the user in the rule actions. - -@itemize - -@item -@samp{char *yytext} holds the text of the current token. -It may be modified but not lengthened (you cannot -append characters to the end). - -If the special directive @samp{%array} appears in the -first section of the scanner description, then -@code{yytext} is instead declared @samp{char yytext[YYLMAX]}, -where @code{YYLMAX} is a macro definition that you can -redefine in the first section if you don't like the -default value (generally 8KB). Using @samp{%array} -results in somewhat slower scanners, but the value -of @code{yytext} becomes immune to calls to @samp{input()} and -@samp{unput()}, which potentially destroy its value when -@code{yytext} is a character pointer. The opposite of -@samp{%array} is @samp{%pointer}, which is the default. - -You cannot use @samp{%array} when generating C++ scanner -classes (the @samp{-+} flag). - -@item -@samp{int yyleng} holds the length of the current token. - -@item -@samp{FILE *yyin} is the file which by default @code{flex} reads -from. It may be redefined but doing so only makes -sense before scanning begins or after an EOF has -been encountered. Changing it in the midst of -scanning will have unexpected results since @code{flex} -buffers its input; use @samp{yyrestart()} instead. Once -scanning terminates because an end-of-file has been -seen, you can assign @code{yyin} at the new input file and -then call the scanner again to continue scanning. - -@item -@samp{void yyrestart( FILE *new_file )} may be called to -point @code{yyin} at the new input file. The switch-over -to the new file is immediate (any previously -buffered-up input is lost). Note that calling -@samp{yyrestart()} with @code{yyin} as an argument thus throws -away the current input buffer and continues -scanning the same input file. - -@item -@samp{FILE *yyout} is the file to which @samp{ECHO} actions are -done. It can be reassigned by the user. - -@item -@code{YY_CURRENT_BUFFER} returns a @code{YY_BUFFER_STATE} handle -to the current buffer. - -@item -@code{YY_START} returns an integer value corresponding to -the current start condition. You can subsequently -use this value with @code{BEGIN} to return to that start -condition. -@end itemize - -@node YACC interface, Options, User variables, Top -@section Interfacing with @code{yacc} - -One of the main uses of @code{flex} is as a companion to the @code{yacc} -parser-generator. @code{yacc} parsers expect to call a routine -named @samp{yylex()} to find the next input token. The routine -is supposed to return the type of the next token as well -as putting any associated value in the global @code{yylval}. To -use @code{flex} with @code{yacc}, one specifies the @samp{-d} option to @code{yacc} to -instruct it to generate the file @file{y.tab.h} containing -definitions of all the @samp{%tokens} appearing in the @code{yacc} input. -This file is then included in the @code{flex} scanner. For -example, if one of the tokens is "TOK_NUMBER", part of the -scanner might look like: - -@example -%@{ -#include "y.tab.h" -%@} - -%% - -[0-9]+ yylval = atoi( yytext ); return TOK_NUMBER; -@end example - -@node Options, Performance, YACC interface, Top -@section Options -@code{flex} has the following options: - -@table @samp -@item -b -Generate backing-up information to @file{lex.backup}. -This is a list of scanner states which require -backing up and the input characters on which they -do so. By adding rules one can remove backing-up -states. If @emph{all} backing-up states are eliminated -and @samp{-Cf} or @samp{-CF} is used, the generated scanner will -run faster (see the @samp{-p} flag). Only users who wish -to squeeze every last cycle out of their scanners -need worry about this option. (See the section on -Performance Considerations below.) - -@item -c -is a do-nothing, deprecated option included for -POSIX compliance. - -@item -d -makes the generated scanner run in @dfn{debug} mode. -Whenever a pattern is recognized and the global -@code{yy_flex_debug} is non-zero (which is the default), -the scanner will write to @code{stderr} a line of the -form: - -@example ---accepting rule at line 53 ("the matched text") -@end example - -The line number refers to the location of the rule -in the file defining the scanner (i.e., the file -that was fed to flex). Messages are also generated -when the scanner backs up, accepts the default -rule, reaches the end of its input buffer (or -encounters a NUL; at this point, the two look the -same as far as the scanner's concerned), or reaches -an end-of-file. - -@item -f -specifies @dfn{fast scanner}. No table compression is -done and stdio is bypassed. The result is large -but fast. This option is equivalent to @samp{-Cfr} (see -below). - -@item -h -generates a "help" summary of @code{flex's} options to -@code{stdout} and then exits. @samp{-?} and @samp{--help} are synonyms -for @samp{-h}. - -@item -i -instructs @code{flex} to generate a @emph{case-insensitive} -scanner. The case of letters given in the @code{flex} input -patterns will be ignored, and tokens in the input -will be matched regardless of case. The matched -text given in @code{yytext} will have the preserved case -(i.e., it will not be folded). - -@item -l -turns on maximum compatibility with the original -AT&T @code{lex} implementation. Note that this does not -mean @emph{full} compatibility. Use of this option costs -a considerable amount of performance, and it cannot -be used with the @samp{-+, -f, -F, -Cf}, or @samp{-CF} options. -For details on the compatibilities it provides, see -the section "Incompatibilities With Lex And POSIX" -below. This option also results in the name -@code{YY_FLEX_LEX_COMPAT} being #define'd in the generated -scanner. - -@item -n -is another do-nothing, deprecated option included -only for POSIX compliance. - -@item -p -generates a performance report to stderr. The -report consists of comments regarding features of -the @code{flex} input file which will cause a serious loss -of performance in the resulting scanner. If you -give the flag twice, you will also get comments -regarding features that lead to minor performance -losses. - -Note that the use of @code{REJECT}, @samp{%option yylineno} and -variable trailing context (see the Deficiencies / Bugs section below) -entails a substantial performance penalty; use of @samp{yymore()}, -the @samp{^} operator, and the @samp{-I} flag entail minor performance -penalties. - -@item -s -causes the @dfn{default rule} (that unmatched scanner -input is echoed to @code{stdout}) to be suppressed. If -the scanner encounters input that does not match -any of its rules, it aborts with an error. This -option is useful for finding holes in a scanner's -rule set. - -@item -t -instructs @code{flex} to write the scanner it generates to -standard output instead of @file{lex.yy.c}. - -@item -v -specifies that @code{flex} should write to @code{stderr} a -summary of statistics regarding the scanner it -generates. Most of the statistics are meaningless to -the casual @code{flex} user, but the first line identifies -the version of @code{flex} (same as reported by @samp{-V}), and -the next line the flags used when generating the -scanner, including those that are on by default. - -@item -w -suppresses warning messages. - -@item -B -instructs @code{flex} to generate a @emph{batch} scanner, the -opposite of @emph{interactive} scanners generated by @samp{-I} -(see below). In general, you use @samp{-B} when you are -@emph{certain} that your scanner will never be used -interactively, and you want to squeeze a @emph{little} more -performance out of it. If your goal is instead to -squeeze out a @emph{lot} more performance, you should be -using the @samp{-Cf} or @samp{-CF} options (discussed below), -which turn on @samp{-B} automatically anyway. - -@item -F -specifies that the @dfn{fast} scanner table -representation should be used (and stdio bypassed). This -representation is about as fast as the full table -representation @samp{(-f)}, and for some sets of patterns -will be considerably smaller (and for others, -larger). In general, if the pattern set contains -both "keywords" and a catch-all, "identifier" rule, -such as in the set: - -@example -"case" return TOK_CASE; -"switch" return TOK_SWITCH; -... -"default" return TOK_DEFAULT; -[a-z]+ return TOK_ID; -@end example - -@noindent -then you're better off using the full table -representation. If only the "identifier" rule is -present and you then use a hash table or some such to -detect the keywords, you're better off using @samp{-F}. - -This option is equivalent to @samp{-CFr} (see below). It -cannot be used with @samp{-+}. - -@item -I -instructs @code{flex} to generate an @emph{interactive} scanner. -An interactive scanner is one that only looks ahead -to decide what token has been matched if it -absolutely must. It turns out that always looking one -extra character ahead, even if the scanner has -already seen enough text to disambiguate the -current token, is a bit faster than only looking ahead -when necessary. But scanners that always look -ahead give dreadful interactive performance; for -example, when a user types a newline, it is not -recognized as a newline token until they enter -@emph{another} token, which often means typing in another -whole line. - -@code{Flex} scanners default to @emph{interactive} unless you use -the @samp{-Cf} or @samp{-CF} table-compression options (see -below). That's because if you're looking for -high-performance you should be using one of these -options, so if you didn't, @code{flex} assumes you'd -rather trade off a bit of run-time performance for -intuitive interactive behavior. Note also that you -@emph{cannot} use @samp{-I} in conjunction with @samp{-Cf} or @samp{-CF}. -Thus, this option is not really needed; it is on by -default for all those cases in which it is allowed. - -You can force a scanner to @emph{not} be interactive by -using @samp{-B} (see above). - -@item -L -instructs @code{flex} not to generate @samp{#line} directives. -Without this option, @code{flex} peppers the generated -scanner with #line directives so error messages in -the actions will be correctly located with respect -to either the original @code{flex} input file (if the -errors are due to code in the input file), or -@file{lex.yy.c} (if the errors are @code{flex's} fault -- you -should report these sorts of errors to the email -address given below). - -@item -T -makes @code{flex} run in @code{trace} mode. It will generate a -lot of messages to @code{stderr} concerning the form of -the input and the resultant non-deterministic and -deterministic finite automata. This option is -mostly for use in maintaining @code{flex}. - -@item -V -prints the version number to @code{stdout} and exits. -@samp{--version} is a synonym for @samp{-V}. - -@item -7 -instructs @code{flex} to generate a 7-bit scanner, i.e., -one which can only recognized 7-bit characters in -its input. The advantage of using @samp{-7} is that the -scanner's tables can be up to half the size of -those generated using the @samp{-8} option (see below). -The disadvantage is that such scanners often hang -or crash if their input contains an 8-bit -character. - -Note, however, that unless you generate your -scanner using the @samp{-Cf} or @samp{-CF} table compression options, -use of @samp{-7} will save only a small amount of table -space, and make your scanner considerably less -portable. @code{Flex's} default behavior is to generate -an 8-bit scanner unless you use the @samp{-Cf} or @samp{-CF}, in -which case @code{flex} defaults to generating 7-bit -scanners unless your site was always configured to -generate 8-bit scanners (as will often be the case -with non-USA sites). You can tell whether flex -generated a 7-bit or an 8-bit scanner by inspecting -the flag summary in the @samp{-v} output as described -above. - -Note that if you use @samp{-Cfe} or @samp{-CFe} (those table -compression options, but also using equivalence -classes as discussed see below), flex still -defaults to generating an 8-bit scanner, since -usually with these compression options full 8-bit -tables are not much more expensive than 7-bit -tables. - -@item -8 -instructs @code{flex} to generate an 8-bit scanner, i.e., -one which can recognize 8-bit characters. This -flag is only needed for scanners generated using -@samp{-Cf} or @samp{-CF}, as otherwise flex defaults to -generating an 8-bit scanner anyway. - -See the discussion of @samp{-7} above for flex's default -behavior and the tradeoffs between 7-bit and 8-bit -scanners. - -@item -+ -specifies that you want flex to generate a C++ -scanner class. See the section on Generating C++ -Scanners below for details. - -@item -C[aefFmr] -controls the degree of table compression and, more -generally, trade-offs between small scanners and -fast scanners. - -@samp{-Ca} ("align") instructs flex to trade off larger -tables in the generated scanner for faster -performance because the elements of the tables are better -aligned for memory access and computation. On some -RISC architectures, fetching and manipulating -long-words is more efficient than with smaller-sized -units such as shortwords. This option can double -the size of the tables used by your scanner. - -@samp{-Ce} directs @code{flex} to construct @dfn{equivalence classes}, -i.e., sets of characters which have identical -lexical properties (for example, if the only appearance -of digits in the @code{flex} input is in the character -class "[0-9]" then the digits '0', '1', @dots{}, '9' -will all be put in the same equivalence class). -Equivalence classes usually give dramatic -reductions in the final table/object file sizes -(typically a factor of 2-5) and are pretty cheap -performance-wise (one array look-up per character -scanned). - -@samp{-Cf} specifies that the @emph{full} scanner tables should -be generated - @code{flex} should not compress the tables -by taking advantages of similar transition -functions for different states. - -@samp{-CF} specifies that the alternate fast scanner -representation (described above under the @samp{-F} flag) -should be used. This option cannot be used with -@samp{-+}. - -@samp{-Cm} directs @code{flex} to construct @dfn{meta-equivalence -classes}, which are sets of equivalence classes (or -characters, if equivalence classes are not being -used) that are commonly used together. -Meta-equivalence classes are often a big win when using -compressed tables, but they have a moderate -performance impact (one or two "if" tests and one array -look-up per character scanned). - -@samp{-Cr} causes the generated scanner to @emph{bypass} use of -the standard I/O library (stdio) for input. -Instead of calling @samp{fread()} or @samp{getc()}, the scanner -will use the @samp{read()} system call, resulting in a -performance gain which varies from system to -system, but in general is probably negligible unless -you are also using @samp{-Cf} or @samp{-CF}. Using @samp{-Cr} can cause -strange behavior if, for example, you read from -@code{yyin} using stdio prior to calling the scanner -(because the scanner will miss whatever text your -previous reads left in the stdio input buffer). - -@samp{-Cr} has no effect if you define @code{YY_INPUT} (see The -Generated Scanner above). - -A lone @samp{-C} specifies that the scanner tables should -be compressed but neither equivalence classes nor -meta-equivalence classes should be used. - -The options @samp{-Cf} or @samp{-CF} and @samp{-Cm} do not make sense -together - there is no opportunity for -meta-equivalence classes if the table is not being -compressed. Otherwise the options may be freely -mixed, and are cumulative. - -The default setting is @samp{-Cem}, which specifies that -@code{flex} should generate equivalence classes and -meta-equivalence classes. This setting provides the -highest degree of table compression. You can trade -off faster-executing scanners at the cost of larger -tables with the following generally being true: - -@example -slowest & smallest - -Cem - -Cm - -Ce - -C - -C@{f,F@}e - -C@{f,F@} - -C@{f,F@}a -fastest & largest -@end example - -Note that scanners with the smallest tables are -usually generated and compiled the quickest, so -during development you will usually want to use the -default, maximal compression. - -@samp{-Cfe} is often a good compromise between speed and -size for production scanners. - -@item -ooutput -directs flex to write the scanner to the file @samp{out-} -@code{put} instead of @file{lex.yy.c}. If you combine @samp{-o} with -the @samp{-t} option, then the scanner is written to -@code{stdout} but its @samp{#line} directives (see the @samp{-L} option -above) refer to the file @code{output}. - -@item -Pprefix -changes the default @samp{yy} prefix used by @code{flex} for all -globally-visible variable and function names to -instead be @var{prefix}. For example, @samp{-Pfoo} changes the -name of @code{yytext} to @file{footext}. It also changes the -name of the default output file from @file{lex.yy.c} to -@file{lex.foo.c}. Here are all of the names affected: - -@example -yy_create_buffer -yy_delete_buffer -yy_flex_debug -yy_init_buffer -yy_flush_buffer -yy_load_buffer_state -yy_switch_to_buffer -yyin -yyleng -yylex -yylineno -yyout -yyrestart -yytext -yywrap -@end example - -(If you are using a C++ scanner, then only @code{yywrap} -and @code{yyFlexLexer} are affected.) Within your scanner -itself, you can still refer to the global variables -and functions using either version of their name; -but externally, they have the modified name. - -This option lets you easily link together multiple -@code{flex} programs into the same executable. Note, -though, that using this option also renames -@samp{yywrap()}, so you now @emph{must} either provide your own -(appropriately-named) version of the routine for -your scanner, or use @samp{%option noyywrap}, as linking -with @samp{-lfl} no longer provides one for you by -default. - -@item -Sskeleton_file -overrides the default skeleton file from which @code{flex} -constructs its scanners. You'll never need this -option unless you are doing @code{flex} maintenance or -development. -@end table - -@code{flex} also provides a mechanism for controlling options -within the scanner specification itself, rather than from -the flex command-line. This is done by including @samp{%option} -directives in the first section of the scanner -specification. You can specify multiple options with a single -@samp{%option} directive, and multiple directives in the first -section of your flex input file. Most options are given -simply as names, optionally preceded by the word "no" -(with no intervening whitespace) to negate their meaning. -A number are equivalent to flex flags or their negation: - -@example -7bit -7 option -8bit -8 option -align -Ca option -backup -b option -batch -B option -c++ -+ option - -caseful or -case-sensitive opposite of -i (default) - -case-insensitive or -caseless -i option - -debug -d option -default opposite of -s option -ecs -Ce option -fast -F option -full -f option -interactive -I option -lex-compat -l option -meta-ecs -Cm option -perf-report -p option -read -Cr option -stdout -t option -verbose -v option -warn opposite of -w option - (use "%option nowarn" for -w) - -array equivalent to "%array" -pointer equivalent to "%pointer" (default) -@end example - -Some @samp{%option's} provide features otherwise not available: - -@table @samp -@item always-interactive -instructs flex to generate a scanner which always -considers its input "interactive". Normally, on -each new input file the scanner calls @samp{isatty()} in -an attempt to determine whether the scanner's input -source is interactive and thus should be read a -character at a time. When this option is used, -however, then no such call is made. - -@item main -directs flex to provide a default @samp{main()} program -for the scanner, which simply calls @samp{yylex()}. This -option implies @code{noyywrap} (see below). - -@item never-interactive -instructs flex to generate a scanner which never -considers its input "interactive" (again, no call -made to @samp{isatty())}. This is the opposite of @samp{always-} -@emph{interactive}. - -@item stack -enables the use of start condition stacks (see -Start Conditions above). - -@item stdinit -if unset (i.e., @samp{%option nostdinit}) initializes @code{yyin} -and @code{yyout} to nil @code{FILE} pointers, instead of @code{stdin} -and @code{stdout}. - -@item yylineno -directs @code{flex} to generate a scanner that maintains the number -of the current line read from its input in the global variable -@code{yylineno}. This option is implied by @samp{%option lex-compat}. - -@item yywrap -if unset (i.e., @samp{%option noyywrap}), makes the -scanner not call @samp{yywrap()} upon an end-of-file, but -simply assume that there are no more files to scan -(until the user points @code{yyin} at a new file and calls -@samp{yylex()} again). -@end table - -@code{flex} scans your rule actions to determine whether you use -the @code{REJECT} or @samp{yymore()} features. The @code{reject} and @code{yymore} -options are available to override its decision as to -whether you use the options, either by setting them (e.g., -@samp{%option reject}) to indicate the feature is indeed used, or -unsetting them to indicate it actually is not used (e.g., -@samp{%option noyymore}). - -Three options take string-delimited values, offset with '=': - -@example -%option outfile="ABC" -@end example - -@noindent -is equivalent to @samp{-oABC}, and - -@example -%option prefix="XYZ" -@end example - -@noindent -is equivalent to @samp{-PXYZ}. - -Finally, - -@example -%option yyclass="foo" -@end example - -@noindent -only applies when generating a C++ scanner (@samp{-+} option). It -informs @code{flex} that you have derived @samp{foo} as a subclass of -@code{yyFlexLexer} so @code{flex} will place your actions in the member -function @samp{foo::yylex()} instead of @samp{yyFlexLexer::yylex()}. -It also generates a @samp{yyFlexLexer::yylex()} member function that -emits a run-time error (by invoking @samp{yyFlexLexer::LexerError()}) -if called. See Generating C++ Scanners, below, for additional -information. - -A number of options are available for lint purists who -want to suppress the appearance of unneeded routines in -the generated scanner. Each of the following, if unset, -results in the corresponding routine not appearing in the -generated scanner: - -@example -input, unput -yy_push_state, yy_pop_state, yy_top_state -yy_scan_buffer, yy_scan_bytes, yy_scan_string -@end example - -@noindent -(though @samp{yy_push_state()} and friends won't appear anyway -unless you use @samp{%option stack}). - -@node Performance, C++, Options, Top -@section Performance considerations - -The main design goal of @code{flex} is that it generate -high-performance scanners. It has been optimized for dealing -well with large sets of rules. Aside from the effects on -scanner speed of the table compression @samp{-C} options outlined -above, there are a number of options/actions which degrade -performance. These are, from most expensive to least: - -@example -REJECT -%option yylineno -arbitrary trailing context - -pattern sets that require backing up -%array -%option interactive -%option always-interactive - -'^' beginning-of-line operator -yymore() -@end example - -with the first three all being quite expensive and the -last two being quite cheap. Note also that @samp{unput()} is -implemented as a routine call that potentially does quite -a bit of work, while @samp{yyless()} is a quite-cheap macro; so -if just putting back some excess text you scanned, use -@samp{yyless()}. - -@code{REJECT} should be avoided at all costs when performance is -important. It is a particularly expensive option. - -Getting rid of backing up is messy and often may be an -enormous amount of work for a complicated scanner. In -principal, one begins by using the @samp{-b} flag to generate a -@file{lex.backup} file. For example, on the input - -@example -%% -foo return TOK_KEYWORD; -foobar return TOK_KEYWORD; -@end example - -@noindent -the file looks like: - -@example -State #6 is non-accepting - - associated rule line numbers: - 2 3 - out-transitions: [ o ] - jam-transitions: EOF [ \001-n p-\177 ] - -State #8 is non-accepting - - associated rule line numbers: - 3 - out-transitions: [ a ] - jam-transitions: EOF [ \001-` b-\177 ] - -State #9 is non-accepting - - associated rule line numbers: - 3 - out-transitions: [ r ] - jam-transitions: EOF [ \001-q s-\177 ] - -Compressed tables always back up. -@end example - -The first few lines tell us that there's a scanner state -in which it can make a transition on an 'o' but not on any -other character, and that in that state the currently -scanned text does not match any rule. The state occurs -when trying to match the rules found at lines 2 and 3 in -the input file. If the scanner is in that state and then -reads something other than an 'o', it will have to back up -to find a rule which is matched. With a bit of -head-scratching one can see that this must be the state it's in -when it has seen "fo". When this has happened, if -anything other than another 'o' is seen, the scanner will -have to back up to simply match the 'f' (by the default -rule). - -The comment regarding State #8 indicates there's a problem -when "foob" has been scanned. Indeed, on any character -other than an 'a', the scanner will have to back up to -accept "foo". Similarly, the comment for State #9 -concerns when "fooba" has been scanned and an 'r' does not -follow. - -The final comment reminds us that there's no point going -to all the trouble of removing backing up from the rules -unless we're using @samp{-Cf} or @samp{-CF}, since there's no -performance gain doing so with compressed scanners. - -The way to remove the backing up is to add "error" rules: - -@example -%% -foo return TOK_KEYWORD; -foobar return TOK_KEYWORD; - -fooba | -foob | -fo @{ - /* false alarm, not really a keyword */ - return TOK_ID; - @} -@end example - -Eliminating backing up among a list of keywords can also -be done using a "catch-all" rule: - -@example -%% -foo return TOK_KEYWORD; -foobar return TOK_KEYWORD; - -[a-z]+ return TOK_ID; -@end example - -This is usually the best solution when appropriate. - -Backing up messages tend to cascade. With a complicated -set of rules it's not uncommon to get hundreds of -messages. If one can decipher them, though, it often only -takes a dozen or so rules to eliminate the backing up -(though it's easy to make a mistake and have an error rule -accidentally match a valid token. A possible future @code{flex} -feature will be to automatically add rules to eliminate -backing up). - -It's important to keep in mind that you gain the benefits -of eliminating backing up only if you eliminate @emph{every} -instance of backing up. Leaving just one means you gain -nothing. - -@var{Variable} trailing context (where both the leading and -trailing parts do not have a fixed length) entails almost -the same performance loss as @code{REJECT} (i.e., substantial). -So when possible a rule like: - -@example -%% -mouse|rat/(cat|dog) run(); -@end example - -@noindent -is better written: - -@example -%% -mouse/cat|dog run(); -rat/cat|dog run(); -@end example - -@noindent -or as - -@example -%% -mouse|rat/cat run(); -mouse|rat/dog run(); -@end example - -Note that here the special '|' action does @emph{not} provide any -savings, and can even make things worse (see Deficiencies -/ Bugs below). - -Another area where the user can increase a scanner's -performance (and one that's easier to implement) arises from -the fact that the longer the tokens matched, the faster -the scanner will run. This is because with long tokens -the processing of most input characters takes place in the -(short) inner scanning loop, and does not often have to go -through the additional work of setting up the scanning -environment (e.g., @code{yytext}) for the action. Recall the -scanner for C comments: - -@example -%x comment -%% - int line_num = 1; - -"/*" BEGIN(comment); - -[^*\n]* -"*"+[^*/\n]* -\n ++line_num; -"*"+"/" BEGIN(INITIAL); -@end example - -This could be sped up by writing it as: - -@example -%x comment -%% - int line_num = 1; - -"/*" BEGIN(comment); - -[^*\n]* -[^*\n]*\n ++line_num; -"*"+[^*/\n]* -"*"+[^*/\n]*\n ++line_num; -"*"+"/" BEGIN(INITIAL); -@end example - -Now instead of each newline requiring the processing of -another action, recognizing the newlines is "distributed" -over the other rules to keep the matched text as long as -possible. Note that @emph{adding} rules does @emph{not} slow down the -scanner! The speed of the scanner is independent of the -number of rules or (modulo the considerations given at the -beginning of this section) how complicated the rules are -with regard to operators such as '*' and '|'. - -A final example in speeding up a scanner: suppose you want -to scan through a file containing identifiers and -keywords, one per line and with no other extraneous -characters, and recognize all the keywords. A natural first -approach is: - -@example -%% -asm | -auto | -break | -@dots{} etc @dots{} -volatile | -while /* it's a keyword */ - -.|\n /* it's not a keyword */ -@end example - -To eliminate the back-tracking, introduce a catch-all -rule: - -@example -%% -asm | -auto | -break | -... etc ... -volatile | -while /* it's a keyword */ - -[a-z]+ | -.|\n /* it's not a keyword */ -@end example - -Now, if it's guaranteed that there's exactly one word per -line, then we can reduce the total number of matches by a -half by merging in the recognition of newlines with that -of the other tokens: - -@example -%% -asm\n | -auto\n | -break\n | -@dots{} etc @dots{} -volatile\n | -while\n /* it's a keyword */ - -[a-z]+\n | -.|\n /* it's not a keyword */ -@end example - -One has to be careful here, as we have now reintroduced -backing up into the scanner. In particular, while @emph{we} know -that there will never be any characters in the input -stream other than letters or newlines, @code{flex} can't figure -this out, and it will plan for possibly needing to back up -when it has scanned a token like "auto" and then the next -character is something other than a newline or a letter. -Previously it would then just match the "auto" rule and be -done, but now it has no "auto" rule, only a "auto\n" rule. -To eliminate the possibility of backing up, we could -either duplicate all rules but without final newlines, or, -since we never expect to encounter such an input and -therefore don't how it's classified, we can introduce one -more catch-all rule, this one which doesn't include a -newline: - -@example -%% -asm\n | -auto\n | -break\n | -@dots{} etc @dots{} -volatile\n | -while\n /* it's a keyword */ - -[a-z]+\n | -[a-z]+ | -.|\n /* it's not a keyword */ -@end example - -Compiled with @samp{-Cf}, this is about as fast as one can get a -@code{flex} scanner to go for this particular problem. - -A final note: @code{flex} is slow when matching NUL's, -particularly when a token contains multiple NUL's. It's best to -write rules which match @emph{short} amounts of text if it's -anticipated that the text will often include NUL's. - -Another final note regarding performance: as mentioned -above in the section How the Input is Matched, dynamically -resizing @code{yytext} to accommodate huge tokens is a slow -process because it presently requires that the (huge) token -be rescanned from the beginning. Thus if performance is -vital, you should attempt to match "large" quantities of -text but not "huge" quantities, where the cutoff between -the two is at about 8K characters/token. - -@node C++, Incompatibilities, Performance, Top -@section Generating C++ scanners - -@code{flex} provides two different ways to generate scanners for -use with C++. The first way is to simply compile a -scanner generated by @code{flex} using a C++ compiler instead of a C -compiler. You should not encounter any compilations -errors (please report any you find to the email address -given in the Author section below). You can then use C++ -code in your rule actions instead of C code. Note that -the default input source for your scanner remains @code{yyin}, -and default echoing is still done to @code{yyout}. Both of these -remain @samp{FILE *} variables and not C++ @code{streams}. - -You can also use @code{flex} to generate a C++ scanner class, using -the @samp{-+} option, (or, equivalently, @samp{%option c++}), which -is automatically specified if the name of the flex executable ends -in a @samp{+}, such as @code{flex++}. When using this option, flex -defaults to generating the scanner to the file @file{lex.yy.cc} instead -of @file{lex.yy.c}. The generated scanner includes the header file -@file{FlexLexer.h}, which defines the interface to two C++ classes. - -The first class, @code{FlexLexer}, provides an abstract base -class defining the general scanner class interface. It -provides the following member functions: - -@table @samp -@item const char* YYText() -returns the text of the most recently matched -token, the equivalent of @code{yytext}. - -@item int YYLeng() -returns the length of the most recently matched -token, the equivalent of @code{yyleng}. - -@item int lineno() const -returns the current input line number (see @samp{%option yylineno}), -or 1 if @samp{%option yylineno} was not used. - -@item void set_debug( int flag ) -sets the debugging flag for the scanner, equivalent to assigning to -@code{yy_flex_debug} (see the Options section above). Note that you -must build the scanner using @samp{%option debug} to include debugging -information in it. - -@item int debug() const -returns the current setting of the debugging flag. -@end table - -Also provided are member functions equivalent to -@samp{yy_switch_to_buffer(), yy_create_buffer()} (though the -first argument is an @samp{istream*} object pointer and not a -@samp{FILE*}, @samp{yy_flush_buffer()}, @samp{yy_delete_buffer()}, -and @samp{yyrestart()} (again, the first argument is a @samp{istream*} -object pointer). - -The second class defined in @file{FlexLexer.h} is @code{yyFlexLexer}, -which is derived from @code{FlexLexer}. It defines the following -additional member functions: - -@table @samp -@item yyFlexLexer( istream* arg_yyin = 0, ostream* arg_yyout = 0 ) -constructs a @code{yyFlexLexer} object using the given -streams for input and output. If not specified, -the streams default to @code{cin} and @code{cout}, respectively. - -@item virtual int yylex() -performs the same role is @samp{yylex()} does for ordinary -flex scanners: it scans the input stream, consuming -tokens, until a rule's action returns a value. If you derive a subclass -@var{S} -from @code{yyFlexLexer} -and want to access the member functions and variables of -@var{S} -inside @samp{yylex()}, -then you need to use @samp{%option yyclass="@var{S}"} -to inform @code{flex} -that you will be using that subclass instead of @code{yyFlexLexer}. -In this case, rather than generating @samp{yyFlexLexer::yylex()}, -@code{flex} generates @samp{@var{S}::yylex()} -(and also generates a dummy @samp{yyFlexLexer::yylex()} -that calls @samp{yyFlexLexer::LexerError()} -if called). - -@item virtual void switch_streams(istream* new_in = 0, ostream* new_out = 0) -reassigns @code{yyin} to @code{new_in} -(if non-nil) -and @code{yyout} to @code{new_out} -(ditto), deleting the previous input buffer if @code{yyin} -is reassigned. - -@item int yylex( istream* new_in = 0, ostream* new_out = 0 ) -first switches the input streams via @samp{switch_streams( new_in, new_out )} -and then returns the value of @samp{yylex()}. -@end table - -In addition, @code{yyFlexLexer} defines the following protected -virtual functions which you can redefine in derived -classes to tailor the scanner: - -@table @samp -@item virtual int LexerInput( char* buf, int max_size ) -reads up to @samp{max_size} characters into @var{buf} and -returns the number of characters read. To indicate -end-of-input, return 0 characters. Note that -"interactive" scanners (see the @samp{-B} and @samp{-I} flags) -define the macro @code{YY_INTERACTIVE}. If you redefine -@code{LexerInput()} and need to take different actions -depending on whether or not the scanner might be -scanning an interactive input source, you can test -for the presence of this name via @samp{#ifdef}. - -@item virtual void LexerOutput( const char* buf, int size ) -writes out @var{size} characters from the buffer @var{buf}, -which, while NUL-terminated, may also contain -"internal" NUL's if the scanner's rules can match -text with NUL's in them. - -@item virtual void LexerError( const char* msg ) -reports a fatal error message. The default version -of this function writes the message to the stream -@code{cerr} and exits. -@end table - -Note that a @code{yyFlexLexer} object contains its @emph{entire} -scanning state. Thus you can use such objects to create -reentrant scanners. You can instantiate multiple instances of -the same @code{yyFlexLexer} class, and you can also combine -multiple C++ scanner classes together in the same program -using the @samp{-P} option discussed above. -Finally, note that the @samp{%array} feature is not available to -C++ scanner classes; you must use @samp{%pointer} (the default). - -Here is an example of a simple C++ scanner: - -@example - // An example of using the flex C++ scanner class. - -%@{ -int mylineno = 0; -%@} - -string \"[^\n"]+\" - -ws [ \t]+ - -alpha [A-Za-z] -dig [0-9] -name (@{alpha@}|@{dig@}|\$)(@{alpha@}|@{dig@}|[_.\-/$])* -num1 [-+]?@{dig@}+\.?([eE][-+]?@{dig@}+)? -num2 [-+]?@{dig@}*\.@{dig@}+([eE][-+]?@{dig@}+)? -number @{num1@}|@{num2@} - -%% - -@{ws@} /* skip blanks and tabs */ - -"/*" @{ - int c; - - while((c = yyinput()) != 0) - @{ - if(c == '\n') - ++mylineno; - - else if(c == '*') - @{ - if((c = yyinput()) == '/') - break; - else - unput(c); - @} - @} - @} - -@{number@} cout << "number " << YYText() << '\n'; - -\n mylineno++; - -@{name@} cout << "name " << YYText() << '\n'; - -@{string@} cout << "string " << YYText() << '\n'; - -%% - -Version 2.5 December 1994 44 - -int main( int /* argc */, char** /* argv */ ) - @{ - FlexLexer* lexer = new yyFlexLexer; - while(lexer->yylex() != 0) - ; - return 0; - @} -@end example - -If you want to create multiple (different) lexer classes, -you use the @samp{-P} flag (or the @samp{prefix=} option) to rename each -@code{yyFlexLexer} to some other @code{xxFlexLexer}. You then can -include @samp{} in your other sources once per lexer -class, first renaming @code{yyFlexLexer} as follows: - -@example -#undef yyFlexLexer -#define yyFlexLexer xxFlexLexer -#include - -#undef yyFlexLexer -#define yyFlexLexer zzFlexLexer -#include -@end example - -if, for example, you used @samp{%option prefix="xx"} for one of -your scanners and @samp{%option prefix="zz"} for the other. - -IMPORTANT: the present form of the scanning class is -@emph{experimental} and may change considerably between major -releases. - -@node Incompatibilities, Diagnostics, C++, Top -@section Incompatibilities with @code{lex} and POSIX - -@code{flex} is a rewrite of the AT&T Unix @code{lex} tool (the two -implementations do not share any code, though), with some -extensions and incompatibilities, both of which are of -concern to those who wish to write scanners acceptable to -either implementation. Flex is fully compliant with the -POSIX @code{lex} specification, except that when using @samp{%pointer} -(the default), a call to @samp{unput()} destroys the contents of -@code{yytext}, which is counter to the POSIX specification. - -In this section we discuss all of the known areas of -incompatibility between flex, AT&T lex, and the POSIX -specification. - -@code{flex's} @samp{-l} option turns on maximum compatibility with the -original AT&T @code{lex} implementation, at the cost of a major -loss in the generated scanner's performance. We note -below which incompatibilities can be overcome using the @samp{-l} -option. - -@code{flex} is fully compatible with @code{lex} with the following -exceptions: - -@itemize - -@item -The undocumented @code{lex} scanner internal variable @code{yylineno} -is not supported unless @samp{-l} or @samp{%option yylineno} is used. -@code{yylineno} should be maintained on a per-buffer basis, rather -than a per-scanner (single global variable) basis. @code{yylineno} is -not part of the POSIX specification. - -@item -The @samp{input()} routine is not redefinable, though it -may be called to read characters following whatever -has been matched by a rule. If @samp{input()} encounters -an end-of-file the normal @samp{yywrap()} processing is -done. A ``real'' end-of-file is returned by -@samp{input()} as @code{EOF}. - -Input is instead controlled by defining the -@code{YY_INPUT} macro. - -The @code{flex} restriction that @samp{input()} cannot be -redefined is in accordance with the POSIX -specification, which simply does not specify any way of -controlling the scanner's input other than by making -an initial assignment to @code{yyin}. - -@item -The @samp{unput()} routine is not redefinable. This -restriction is in accordance with POSIX. - -@item -@code{flex} scanners are not as reentrant as @code{lex} scanners. -In particular, if you have an interactive scanner -and an interrupt handler which long-jumps out of -the scanner, and the scanner is subsequently called -again, you may get the following message: - -@example -fatal flex scanner internal error--end of buffer missed -@end example - -To reenter the scanner, first use - -@example -yyrestart( yyin ); -@end example - -Note that this call will throw away any buffered -input; usually this isn't a problem with an -interactive scanner. - -Also note that flex C++ scanner classes @emph{are} -reentrant, so if using C++ is an option for you, you -should use them instead. See "Generating C++ -Scanners" above for details. - -@item -@samp{output()} is not supported. Output from the @samp{ECHO} -macro is done to the file-pointer @code{yyout} (default -@code{stdout}). - -@samp{output()} is not part of the POSIX specification. - -@item -@code{lex} does not support exclusive start conditions -(%x), though they are in the POSIX specification. - -@item -When definitions are expanded, @code{flex} encloses them -in parentheses. With lex, the following: - -@example -NAME [A-Z][A-Z0-9]* -%% -foo@{NAME@}? printf( "Found it\n" ); -%% -@end example - -will not match the string "foo" because when the -macro is expanded the rule is equivalent to -"foo[A-Z][A-Z0-9]*?" and the precedence is such that the -'?' is associated with "[A-Z0-9]*". With @code{flex}, the -rule will be expanded to "foo([A-Z][A-Z0-9]*)?" and -so the string "foo" will match. - -Note that if the definition begins with @samp{^} or ends -with @samp{$} then it is @emph{not} expanded with parentheses, to -allow these operators to appear in definitions -without losing their special meanings. But the -@samp{, /}, and @samp{<>} operators cannot be used in a -@code{flex} definition. - -Using @samp{-l} results in the @code{lex} behavior of no -parentheses around the definition. - -The POSIX specification is that the definition be enclosed in -parentheses. - -@item -Some implementations of @code{lex} allow a rule's action to begin on -a separate line, if the rule's pattern has trailing whitespace: - -@example -%% -foo|bar - @{ foobar_action(); @} -@end example - -@code{flex} does not support this feature. - -@item -The @code{lex} @samp{%r} (generate a Ratfor scanner) option is -not supported. It is not part of the POSIX -specification. - -@item -After a call to @samp{unput()}, @code{yytext} is undefined until -the next token is matched, unless the scanner was -built using @samp{%array}. This is not the case with @code{lex} -or the POSIX specification. The @samp{-l} option does -away with this incompatibility. - -@item -The precedence of the @samp{@{@}} (numeric range) operator -is different. @code{lex} interprets "abc@{1,3@}" as "match -one, two, or three occurrences of 'abc'", whereas -@code{flex} interprets it as "match 'ab' followed by one, -two, or three occurrences of 'c'". The latter is -in agreement with the POSIX specification. - -@item -The precedence of the @samp{^} operator is different. @code{lex} -interprets "^foo|bar" as "match either 'foo' at the -beginning of a line, or 'bar' anywhere", whereas -@code{flex} interprets it as "match either 'foo' or 'bar' -if they come at the beginning of a line". The -latter is in agreement with the POSIX specification. - -@item -The special table-size declarations such as @samp{%a} -supported by @code{lex} are not required by @code{flex} scanners; -@code{flex} ignores them. - -@item -The name FLEX_SCANNER is #define'd so scanners may -be written for use with either @code{flex} or @code{lex}. -Scanners also include @code{YY_FLEX_MAJOR_VERSION} and -@code{YY_FLEX_MINOR_VERSION} indicating which version of -@code{flex} generated the scanner (for example, for the -2.5 release, these defines would be 2 and 5 -respectively). -@end itemize - -The following @code{flex} features are not included in @code{lex} or the -POSIX specification: - -@example -C++ scanners -%option -start condition scopes -start condition stacks -interactive/non-interactive scanners -yy_scan_string() and friends -yyterminate() -yy_set_interactive() -yy_set_bol() -YY_AT_BOL() -<> -<*> -YY_DECL -YY_START -YY_USER_ACTION -YY_USER_INIT -#line directives -%@{@}'s around actions -multiple actions on a line -@end example - -@noindent -plus almost all of the flex flags. The last feature in -the list refers to the fact that with @code{flex} you can put -multiple actions on the same line, separated with -semicolons, while with @code{lex}, the following - -@example -foo handle_foo(); ++num_foos_seen; -@end example - -@noindent -is (rather surprisingly) truncated to - -@example -foo handle_foo(); -@end example - -@code{flex} does not truncate the action. Actions that are not -enclosed in braces are simply terminated at the end of the -line. - -@node Diagnostics, Files, Incompatibilities, Top -@section Diagnostics - -@table @samp -@item warning, rule cannot be matched -indicates that the given -rule cannot be matched because it follows other rules that -will always match the same text as it. For example, in -the following "foo" cannot be matched because it comes -after an identifier "catch-all" rule: - -@example -[a-z]+ got_identifier(); -foo got_foo(); -@end example - -Using @code{REJECT} in a scanner suppresses this warning. - -@item warning, -s option given but default rule can be matched -means that it is possible (perhaps only in a particular -start condition) that the default rule (match any single -character) is the only one that will match a particular -input. Since @samp{-s} was given, presumably this is not -intended. - -@item reject_used_but_not_detected undefined -@itemx yymore_used_but_not_detected undefined -These errors can -occur at compile time. They indicate that the scanner -uses @code{REJECT} or @samp{yymore()} but that @code{flex} failed to notice the -fact, meaning that @code{flex} scanned the first two sections -looking for occurrences of these actions and failed to -find any, but somehow you snuck some in (via a #include -file, for example). Use @samp{%option reject} or @samp{%option yymore} -to indicate to flex that you really do use these features. - -@item flex scanner jammed -a scanner compiled with @samp{-s} has -encountered an input string which wasn't matched by any of -its rules. This error can also occur due to internal -problems. - -@item token too large, exceeds YYLMAX -your scanner uses @samp{%array} -and one of its rules matched a string longer than the @samp{YYL-} -@code{MAX} constant (8K bytes by default). You can increase the -value by #define'ing @code{YYLMAX} in the definitions section of -your @code{flex} input. - -@item scanner requires -8 flag to use the character '@var{x}' -Your -scanner specification includes recognizing the 8-bit -character @var{x} and you did not specify the -8 flag, and your -scanner defaulted to 7-bit because you used the @samp{-Cf} or @samp{-CF} -table compression options. See the discussion of the @samp{-7} -flag for details. - -@item flex scanner push-back overflow -you used @samp{unput()} to push -back so much text that the scanner's buffer could not hold -both the pushed-back text and the current token in @code{yytext}. -Ideally the scanner should dynamically resize the buffer -in this case, but at present it does not. - -@item input buffer overflow, can't enlarge buffer because scanner uses REJECT -the scanner was working on matching an -extremely large token and needed to expand the input -buffer. This doesn't work with scanners that use @code{REJECT}. - -@item fatal flex scanner internal error--end of buffer missed -This can occur in an scanner which is reentered after a -long-jump has jumped out (or over) the scanner's -activation frame. Before reentering the scanner, use: - -@example -yyrestart( yyin ); -@end example - -@noindent -or, as noted above, switch to using the C++ scanner class. - -@item too many start conditions in <> construct! -you listed -more start conditions in a <> construct than exist (so you -must have listed at least one of them twice). -@end table - -@node Files, Deficiencies, Diagnostics, Top -@section Files - -@table @file -@item -lfl -library with which scanners must be linked. - -@item lex.yy.c -generated scanner (called @file{lexyy.c} on some systems). - -@item lex.yy.cc -generated C++ scanner class, when using @samp{-+}. - -@item -header file defining the C++ scanner base class, -@code{FlexLexer}, and its derived class, @code{yyFlexLexer}. - -@item flex.skl -skeleton scanner. This file is only used when -building flex, not when flex executes. - -@item lex.backup -backing-up information for @samp{-b} flag (called @file{lex.bck} -on some systems). -@end table - -@node Deficiencies, See also, Files, Top -@section Deficiencies / Bugs - -Some trailing context patterns cannot be properly matched -and generate warning messages ("dangerous trailing -context"). These are patterns where the ending of the first -part of the rule matches the beginning of the second part, -such as "zx*/xy*", where the 'x*' matches the 'x' at the -beginning of the trailing context. (Note that the POSIX -draft states that the text matched by such patterns is -undefined.) - -For some trailing context rules, parts which are actually -fixed-length are not recognized as such, leading to the -abovementioned performance loss. In particular, parts -using '|' or @{n@} (such as "foo@{3@}") are always considered -variable-length. - -Combining trailing context with the special '|' action can -result in @emph{fixed} trailing context being turned into the -more expensive @var{variable} trailing context. For example, in -the following: - -@example -%% -abc | -xyz/def -@end example - -Use of @samp{unput()} invalidates yytext and yyleng, unless the -@samp{%array} directive or the @samp{-l} option has been used. - -Pattern-matching of NUL's is substantially slower than -matching other characters. - -Dynamic resizing of the input buffer is slow, as it -entails rescanning all the text matched so far by the -current (generally huge) token. - -Due to both buffering of input and read-ahead, you cannot -intermix calls to routines, such as, for -example, @samp{getchar()}, with @code{flex} rules and expect it to work. -Call @samp{input()} instead. - -The total table entries listed by the @samp{-v} flag excludes the -number of table entries needed to determine what rule has -been matched. The number of entries is equal to the -number of DFA states if the scanner does not use @code{REJECT}, and -somewhat greater than the number of states if it does. - -@code{REJECT} cannot be used with the @samp{-f} or @samp{-F} options. - -The @code{flex} internal algorithms need documentation. - -@node See also, Author, Deficiencies, Top -@section See also - -@code{lex}(1), @code{yacc}(1), @code{sed}(1), @code{awk}(1). - -John Levine, Tony Mason, and Doug Brown: Lex & Yacc; -O'Reilly and Associates. Be sure to get the 2nd edition. - -M. E. Lesk and E. Schmidt, LEX - Lexical Analyzer Generator. - -Alfred Aho, Ravi Sethi and Jeffrey Ullman: Compilers: -Principles, Techniques and Tools; Addison-Wesley (1986). -Describes the pattern-matching techniques used by @code{flex} -(deterministic finite automata). - -@node Author, , See also, Top -@section Author - -Vern Paxson, with the help of many ideas and much inspiration from -Van Jacobson. Original version by Jef Poskanzer. The fast table -representation is a partial implementation of a design done by Van -Jacobson. The implementation was done by Kevin Gong and Vern Paxson. - -Thanks to the many @code{flex} beta-testers, feedbackers, and -contributors, especially Francois Pinard, Casey Leedom, Stan -Adermann, Terry Allen, David Barker-Plummer, John Basrai, Nelson -H.F. Beebe, @samp{benson@@odi.com}, Karl Berry, Peter A. Bigot, -Simon Blanchard, Keith Bostic, Frederic Brehm, Ian Brockbank, Kin -Cho, Nick Christopher, Brian Clapper, J.T. Conklin, Jason Coughlin, -Bill Cox, Nick Cropper, Dave Curtis, Scott David Daniels, Chris -G. Demetriou, Theo Deraadt, Mike Donahue, Chuck Doucette, Tom Epperly, -Leo Eskin, Chris Faylor, Chris Flatters, Jon Forrest, Joe Gayda, Kaveh -R. Ghazi, Eric Goldman, Christopher M. Gould, Ulrich Grepel, Peer -Griebel, Jan Hajic, Charles Hemphill, NORO Hideo, Jarkko Hietaniemi, -Scott Hofmann, Jeff Honig, Dana Hudes, Eric Hughes, John Interrante, -Ceriel Jacobs, Michal Jaegermann, Sakari Jalovaara, Jeffrey R. Jones, -Henry Juengst, Klaus Kaempf, Jonathan I. Kamens, Terrence O Kane, -Amir Katz, @samp{ken@@ken.hilco.com}, Kevin B. Kenny, Steve Kirsch, -Winfried Koenig, Marq Kole, Ronald Lamprecht, Greg Lee, Rohan Lenard, -Craig Leres, John Levine, Steve Liddle, Mike Long, Mohamed el Lozy, -Brian Madsen, Malte, Joe Marshall, Bengt Martensson, Chris Metcalf, -Luke Mewburn, Jim Meyering, R. Alexander Milowski, Erik Naggum, -G.T. Nicol, Landon Noll, James Nordby, Marc Nozell, Richard Ohnemus, -Karsten Pahnke, Sven Panne, Roland Pesch, Walter Pelissero, Gaumond -Pierre, Esmond Pitt, Jef Poskanzer, Joe Rahmeh, Jarmo Raiha, Frederic -Raimbault, Pat Rankin, Rick Richardson, Kevin Rodgers, Kai Uwe Rommel, -Jim Roskind, Alberto Santini, Andreas Scherer, Darrell Schiebel, Raf -Schietekat, Doug Schmidt, Philippe Schnoebelen, Andreas Schwab, Alex -Siegel, Eckehard Stolz, Jan-Erik Strvmquist, Mike Stump, Paul Stuart, -Dave Tallman, Ian Lance Taylor, Chris Thewalt, Richard M. Timoney, -Jodi Tsai, Paul Tuinenga, Gary Weik, Frank Whaley, Gerhard Wilhelms, -Kent Williams, Ken Yap, Ron Zellar, Nathan Zelle, David Zuhn, and -those whose names have slipped my marginal mail-archiving skills but -whose contributions are appreciated all the same. - -Thanks to Keith Bostic, Jon Forrest, Noah Friedman, John Gilmore, -Craig Leres, John Levine, Bob Mulcahy, G.T. Nicol, Francois Pinard, -Rich Salz, and Richard Stallman for help with various distribution -headaches. - -Thanks to Esmond Pitt and Earle Horton for 8-bit character support; -to Benson Margulies and Fred Burke for C++ support; to Kent Williams -and Tom Epperly for C++ class support; to Ove Ewerlid for support of -NUL's; and to Eric Hughes for support of multiple buffers. - -This work was primarily done when I was with the Real Time Systems -Group at the Lawrence Berkeley Laboratory in Berkeley, CA. Many thanks -to all there for the support I received. - -Send comments to @samp{vern@@ee.lbl.gov}. - -@c @node Index, , Top, Top -@c @unnumbered Index -@c -@c @printindex cp - -@contents -@bye - -@c Local variables: -@c texinfo-column-for-description: 32 -@c End: diff --git a/commands/flex-2.5.4/Makefile.in b/commands/flex-2.5.4/Makefile.in deleted file mode 100644 index 53d043d13..000000000 --- a/commands/flex-2.5.4/Makefile.in +++ /dev/null @@ -1,264 +0,0 @@ -# @(#) $Header$ (LBL) - -@SET_MAKE@ - -# Possible values for DEFS: -# -# By default, flex generates 8-bit scanners when using table compression, -# and 7-bit scanners when using uncompressed tables (-f or -F options). -# For flex to always generate 8-bit scanners, add "-DDEFAULT_CSIZE=256" -# to DEFS. -# -# For Vax/VMS, add "-DVMS" to DEFS. -# -# For MS-DOS, add "-DMS_DOS" to DEFS. See the directory MISC/MSDOS for -# additional info. - -CFLAGS = @CFLAGS@ -D_POSIX_SOURCE=1 -CPPFLAGS = @CPPFLAGS@ -DEFS = @DEFS@ -LDFLAGS = @LDFLAGS@ -LIBS = @LIBS@ - -# Installation targeting. Files will be installed under the tree -# rooted at prefix. flex will be installed in bindir, libfl.a in -# libdir, FlexLexer.h will be installed in includedir, and the manual -# pages will be installed in mandir with extension manext. -# -# Raw, unformatted troff source will be installed if INSTALLMAN=man, -# nroff preformatted versions will be installed if INSTALLMAN=cat. - -prefix = @prefix@ -exec_prefix = @exec_prefix@ -bindir = $(exec_prefix)/bin -libdir = @libdir@ -includedir = /usr/local/include -manext = 1 -mandir = $(prefix)/man/man$(manext) - -# You can define these to be "lex" and "libl.a" if you want to replace -# lex at your site. -FLEX = flex -FLEXLIB = libfl.a - -INSTALLMAN = man - -SHELL = /bin/sh -srcdir = @srcdir@ -VPATH = @srcdir@ - -LN_S = @LN_S@ -YACC = @YACC@ -CC = @CC@ -AR = @AR@ -RANLIB = @RANLIB@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ - -# You normally do not need to modify anything below this point. -# ------------------------------------------------------------ - -CPPFLAGS = -I. -I$(srcdir) - -.c.o: - $(CC) -c $(CPPFLAGS) $(CFLAGS) $< - -HEADERS = flexdef.h version.h - -SOURCES = ccl.c dfa.c ecs.c gen.c main.c misc.c nfa.c parse.y \ - scan.l skel.c sym.c tblcmp.c yylex.c -OBJECTS = ccl.o dfa.o ecs.o gen.o main.o misc.o nfa.o parse.o \ - scan.o skel.o sym.o tblcmp.o yylex.o @ALLOCA@ - -LIBSRCS = libmain.c libyywrap.c -LIBOBJS = libmain.o libyywrap.o - -LINTSRCS = ccl.c dfa.c ecs.c gen.c main.c misc.c nfa.c parse.c \ - scan.c skel.c sym.c tblcmp.c yylex.c - -DISTFILES = README NEWS COPYING INSTALL FlexLexer.h \ - configure.in conf.in Makefile.in mkskel.sh flex.skl \ - $(HEADERS) $(SOURCES) $(LIBSRCS) MISC \ - flex.1 scan.c install.sh mkinstalldirs configure - -DIST_NAME = flex - -# which "flex" to use to generate scan.c from scan.l -FLEX_EXEC = ./$(FLEX) -FLEX_FLAGS = -t $(PERF_REPORT) -COMPRESSION = -PERF_REPORT = -p - -all: $(FLEX) - -$(FLEX): .bootstrap $(OBJECTS) $(FLEXLIB) - $(CC) $(CFLAGS) -o $(FLEX) $(LDFLAGS) $(OBJECTS) $(FLEXLIB) $(LIBS) - /usr/bin/install -S256k $(FLEX) - -.bootstrap: initscan.c - @rm -f scan.c - cp $(srcdir)/initscan.c scan.c - touch .bootstrap - -parse.c: parse.y - $(YACC) -d $(srcdir)/parse.y - @sed '/extern char.*malloc/d' parse.tmp - @mv parse.tmp parse.c - @mv y.tab.h parse.h - @rm -f y.tab.c - -parse.h: parse.c - -scan.c: scan.l - $(FLEX_EXEC) $(FLEX_FLAGS) $(COMPRESSION) $(srcdir)/scan.l >scan.c - @sed s,\"$(srcdir)/scan.l\",\"scan.l\", scan.tmp - @mv scan.tmp scan.c - -scan.o: scan.c parse.h flexdef.h config.h -yylex.o: yylex.c parse.h flexdef.h config.h - -skel.c: flex.skl mkskel.sh - $(SHELL) $(srcdir)/mkskel.sh $(srcdir)/flex.skl >skel.c - -main.o: main.c flexdef.h config.h version.h -ccl.o: ccl.c flexdef.h config.h -dfa.o: dfa.c flexdef.h config.h -ecs.o: ecs.c flexdef.h config.h -gen.o: gen.c flexdef.h config.h -misc.o: misc.c flexdef.h config.h -nfa.o: nfa.c flexdef.h config.h -parse.o: parse.c flexdef.h config.h -skel.o: skel.c flexdef.h config.h -sym.o: sym.c flexdef.h config.h -tblcmp.o: tblcmp.c flexdef.h config.h - -alloca.o: alloca.c - $(CC) $(CPPFLAGS) $(CFLAGS) -c -Dxmalloc=yy_flex_xmalloc alloca.c - -alloca.c: $(srcdir)/MISC/alloca.c - @rm -f alloca.c - cp $(srcdir)/MISC/alloca.c . - -test: check -check: $(FLEX) - $(FLEX_EXEC) $(FLEX_FLAGS) $(COMPRESSION) $(srcdir)/scan.l \ - | sed s,\"$(srcdir)/scan.l\",\"scan.l\", \ - | diff scan.c - - @echo "Check successful, using COMPRESSION=\"$(COMPRESSION)\"" - -bigcheck: - rm -f scan.c ; $(MAKE) COMPRESSION="-C" check - rm -f scan.c ; $(MAKE) COMPRESSION="-Ce" check - rm -f scan.c ; $(MAKE) COMPRESSION="-Cm" check - rm -f scan.c ; $(MAKE) COMPRESSION="-f" check - rm -f scan.c ; $(MAKE) COMPRESSION="-Cfea" check - rm -f scan.c ; $(MAKE) COMPRESSION="-CFer" check - rm -f scan.c ; $(MAKE) COMPRESSION="-l" PERF_REPORT="" check - rm -f scan.c ; $(MAKE) - @echo "All checks successful" - -$(FLEXLIB): $(LIBOBJS) - $(AR) cru $(FLEXLIB) $(LIBOBJS) - -$(RANLIB) $(FLEXLIB) - -$(FLEX).man: flex.1 - cd $(srcdir) && nroff -man flex.1 >$(FLEX).man - -install: $(FLEX) installlib installdirs install.$(INSTALLMAN) - $(INSTALL_PROGRAM) $(FLEX) $(bindir)/$(FLEX) - @rm -f $(bindir)/$(FLEX)++ - cd $(bindir) && $(LN_S) $(FLEX) $(FLEX)++ - $(INSTALL_DATA) $(srcdir)/FlexLexer.h $(includedir)/FlexLexer.h - -installlib: $(FLEXLIB) - $(INSTALL_DATA) $(FLEXLIB) $(libdir)/$(FLEXLIB) - -cd $(libdir) && $(RANLIB) $(FLEXLIB) - -# Note, the following rules delete any vestigial flexdoc installed -# for a prior flex release. -install.man: flex.1 - rm -f $(mandir)/$(FLEX)doc.$(manext) - $(INSTALL_DATA) $(srcdir)/flex.1 $(mandir)/$(FLEX).$(manext) - -install.cat: $(FLEX).man - rm -f $(mandir)/$(FLEX)doc.$(manext) - $(INSTALL_DATA) $(srcdir)/$(FLEX).man $(mandir)/$(FLEX).$(manext) - -installdirs: - $(SHELL) $(srcdir)/mkinstalldirs \ - $(bindir) $(libdir) $(includedir) $(mandir) - -uninstall: - rm -f $(bindir)/$(FLEX) $(bindir)/$(FLEX)++ - rm -f $(libdir)/$(FLEXLIB) - rm -f $(includedir)/FlexLexer.h - rm -f $(mandir)/$(FLEX).$(manext) $(mandir)/$(FLEX)doc.$(manext) - -tags: $(SOURCES) - ctags $(SOURCES) - -TAGS: $(SOURCES) - etags $(SOURCES) - -lint: $(LINTSRCS) - lint -Dconst= $(LINTSRCS) > flex.lint - -gcc-lint: $(LINTSRCS) - gcc -Dlint -Wall $(LINTSRCS) >flex.gcc-lint 2>&1 - -mostlyclean: - rm -f a.out *.bak core errs scan.tmp - -clean: mostlyclean - rm -f flex parse.c parse.h *.o alloca.c *.lint lex.yy.c lex.yy.cc \ - $(FLEXLIB) config.log config.cache - -distclean: clean - rm -f .bootstrap $(FLEX) scan.c tags TAGS Makefile config.status \ - config.h stamp-h config.log config.cache - -maintainer-clean: distclean - @echo "This command is intended for maintainers to use;" - @echo "it deletes files that may require special tools to rebuild." - rm -f $(FLEX).man skel.c flex*.tar.gz flex*.tar.Z - -dist: $(FLEX) $(DISTFILES) parse.c parse.h $(srcdir)/$(FLEX).man - $(MAKE) DIST_NAME=flex-`sed $(DIST_NAME)/MISC/flex.man - tar chf $(DIST_NAME).tar $(DIST_NAME) - compress <$(DIST_NAME).tar >$(DIST_NAME).tar.Z - gzip <$(DIST_NAME).tar >$(DIST_NAME).tar.gz - @rm $(DIST_NAME).tar - -# For an explanation of the following Makefile rules, see node -# `Automatic Remaking' in GNU Autoconf documentation. -Makefile: $(srcdir)/Makefile.in config.status - CONFIG_FILES=$@ CONFIG_HEADERS= ./config.status -config.status: configure - ./config.status --recheck -configure: configure.in - cd $(srcdir) && autoconf -#config.h: stamp-h -stamp-h: conf.in config.status - CONFIG_FILES= CONFIG_HEADERS=config.h:conf.in ./config.status - echo timestamp >stamp-h -# conf.in: stamp-h.in -# stamp-h.in: configure.in acconfig.h -# cd $(srcdir) && autoheader -# config.h.in conf.in -# cho timestamp > $(srcdir)/stamp-h.in - -# Tell versions [3.59,3.63) of GNU make not to export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/commands/flex-2.5.4/README b/commands/flex-2.5.4/README deleted file mode 100644 index 7a4224dca..000000000 --- a/commands/flex-2.5.4/README +++ /dev/null @@ -1,60 +0,0 @@ -This is release 2.5 of flex. See "version.h" for the exact patch-level. - -See the file "NEWS" to find out what is new in this Flex release. - -Read the file "INSTALL" for general installation directives. Peek near -the beginning of the file "Makefile.in" for special DEFS values. On most -systems, you can just run the "configure" script and type "make" to build -flex; then "make check" to test whether it built correctly; and if it did, -then "make install" to install it. - -If you're feeling adventurous, you can also issue "make bigcheck" (be -prepared to wait a while). - -Note that flex is distributed under a copyright very similar to that of -BSD Unix, and not under the GNU General Public License (GPL), except for -the "configure" script, which is covered by the GPL. - -Many thanks to the 2.5 beta-testers for finding bugs and helping test and -increase portability: Stan Adermann, Scott David Daniels, Charles Elliott, -Joe Gayda, Chris Meier, James Nordby, Terrence O'Kane, Karsten Pahnke, -Francois Pinard, Pat Rankin, Andreas Scherer, Marc Wiese, Nathan Zelle. - -Please send bug reports and feedback to: Vern Paxson (vern@ee.lbl.gov). - - -The flex distribution consists of the following files: - - README This message - - NEWS Differences between the various releases - - INSTALL General installation information - - COPYING flex's copyright - - conf.in, configure.in, configure, Makefile.in, install.sh, - mkinstalldirs - elements of the "autoconf" auto-configuration process - - flexdef.h, parse.y, scan.l, ccl.c, dfa.c, ecs.c, gen.c, main.c, - misc.c, nfa.c, sym.c, tblcmp.c, yylex.c - source files - - version.h version of this flex release - - flex.skl flex scanner skeleton - mkskel.sh script for converting flex.skl to C source file skel.c - skel.c pre-converted C version of flex.skl - - libmain.c flex library (-lfl) sources - libyywrap.c - - initscan.c pre-flex'd version of scan.l - - FlexLexer.h header file for C++ lexer class - - flex.1 user documentation - - MISC/ a directory containing miscellaneous contributions. - See MISC/README for details. diff --git a/commands/flex-2.5.4/build b/commands/flex-2.5.4/build deleted file mode 100755 index 2645b94d6..000000000 --- a/commands/flex-2.5.4/build +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh - -INSTALL="install -o bin" -CCACHE=config.cache -rm -f $CCACHE -if [ -f Makefile ] -then make distclean -fi -L=libfl.a -YACC=/usr/bin/yacc RANLIB=true AR=ar CONFIG_SHELL=/bin/bigsh CC=cc /bin/bigsh ./configure -make clean all - -$INSTALL -m 755 flex /usr/bin -$INSTALL -l h /usr/bin/flex /usr/bin/flex++ -$INSTALL FlexLexer.h /usr/local/include -$INSTALL libfl.a /usr/lib/i386 - -if [ -f /usr/gnu/bin/gcc ] -then PATH=/usr/gnu/bin:$PATH - rm -f $CCACHE - YACC=/usr/bin/yacc CC=gcc CONFIG_SHELL=/bin/bigsh AR=gar /bin/bigsh ./configure - make clean $L - $INSTALL libfl.a /usr/gnu/lib -fi diff --git a/commands/flex-2.5.4/conf.in b/commands/flex-2.5.4/conf.in deleted file mode 100644 index 6cdcebebf..000000000 --- a/commands/flex-2.5.4/conf.in +++ /dev/null @@ -1,25 +0,0 @@ -/* $Header$ */ - -/* Define to empty if the keyword does not work. */ -#undef const - -/* Define to `unsigned' if doesn't define. */ -#undef size_t - -/* Define if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* Define if you have the header file. */ -#undef HAVE_MALLOC_H - -/* Define if you have the header file. */ -#undef HAVE_STRING_H - -/* Define if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define if you have and it should be used (not on Ultrix). */ -#undef HAVE_ALLOCA_H - -/* Define if platform-specific command line handling is necessary. */ -#undef NEED_ARGV_FIXUP diff --git a/commands/flex-2.5.4/configure b/commands/flex-2.5.4/configure deleted file mode 100755 index ddd4d77a0..000000000 --- a/commands/flex-2.5.4/configure +++ /dev/null @@ -1,1633 +0,0 @@ -#!/bin/sh - -# Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.1 -# Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. -# -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. - -# Defaults: -ac_help= -ac_default_prefix=/usr/local -# Any additions from configure.in: - -# Initialize some variables set by options. -# The variables have the same names as the options, with -# dashes changed to underlines. -build=NONE -cache_file=./config.cache -exec_prefix=NONE -host=NONE -no_create= -nonopt=NONE -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -target=NONE -verbose= -x_includes=NONE -x_libraries=NONE - -# Initialize some other variables. -subdirs= - -ac_prev= -for ac_option -do - - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval "$ac_prev=\$ac_option" - ac_prev= - continue - fi - - case "$ac_option" in - -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; - *) ac_optarg= ;; - esac - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case "$ac_option" in - - -build | --build | --buil | --bui | --bu | --b) - ac_prev=build ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=* | --b=*) - build="$ac_optarg" ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file="$ac_optarg" ;; - - -disable-* | --disable-*) - ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - eval "enable_${ac_feature}=no" ;; - - -enable-* | --enable-*) - ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; - *) ac_optarg=yes ;; - esac - eval "enable_${ac_feature}='$ac_optarg'" ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix="$ac_optarg" ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he) - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat << EOF -Usage: configure [options] [host] -Options: [defaults in brackets after descriptions] -Configuration: - --cache-file=FILE cache test results in FILE - --help print this message - --no-create do not create output files - --quiet, --silent do not print \`checking...' messages - --version print the version of autoconf that created configure -Directory and file names: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=PREFIX install architecture-dependent files in PREFIX - [same as prefix] - --srcdir=DIR find the sources in DIR [configure dir or ..] - --program-prefix=PREFIX prepend PREFIX to installed program names - --program-suffix=SUFFIX append SUFFIX to installed program names - --program-transform-name=PROGRAM run sed PROGRAM on installed program names -Host type: - --build=BUILD configure for building on BUILD [BUILD=HOST] - --host=HOST configure for HOST [guessed] - --target=TARGET configure for TARGET [TARGET=HOST] -Features and packages: - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] - --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --x-includes=DIR X include files are in DIR - --x-libraries=DIR X library files are in DIR ---enable and --with options recognized:$ac_help -EOF - exit 0 ;; - - -host | --host | --hos | --ho) - ac_prev=host ;; - -host=* | --host=* | --hos=* | --ho=*) - host="$ac_optarg" ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix="$ac_optarg" ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix="$ac_optarg" ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix="$ac_optarg" ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name="$ac_optarg" ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site="$ac_optarg" ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir="$ac_optarg" ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target="$ac_optarg" ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.1" - exit 0 ;; - - -with-* | --with-*) - ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi - ac_package=`echo $ac_package| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; - *) ac_optarg=yes ;; - esac - eval "with_${ac_package}='$ac_optarg'" ;; - - -without-* | --without-*) - ac_package=`echo $ac_option|sed -e 's/-*without-//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi - ac_package=`echo $ac_package| sed 's/-/_/g'` - eval "with_${ac_package}=no" ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes="$ac_optarg" ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries="$ac_optarg" ;; - - -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } - ;; - - *) - if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then - echo "configure: warning: $ac_option: invalid host type" 1>&2 - fi - if test "x$nonopt" != xNONE; then - { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } - fi - nonopt="$ac_option" - ;; - - esac -done - -if test -n "$ac_prev"; then - { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } -fi - -trap 'rm -fr conftest* confdefs* core $ac_clean_files; exit 1' 1 2 15 - -# File descriptor usage: -# 0 unused; standard input -# 1 file creation -# 2 errors and warnings -# 3 unused; some systems may open it to /dev/tty -# 4 checking for... messages and results -# 5 compiler messages saved in config.log -if test "$silent" = yes; then - exec 4>/dev/null -else - exec 4>&1 -fi -exec 5>./config.log - -echo "\ -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. -" 1>&5 - -# Strip out --no-create and --no-recursion so they do not pile up. -# Also quote any args containing shell metacharacters. -ac_configure_args= -for ac_arg -do - case "$ac_arg" in - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) ;; - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) - ac_configure_args="$ac_configure_args '$ac_arg'" ;; - *) ac_configure_args="$ac_configure_args $ac_arg" ;; - esac -done - -# NLS nuisances. -# Only set LANG and LC_ALL to C if already set. -# These must not be set unconditionally because not all systems understand -# e.g. LANG=C (notably SCO). -if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi -if test "${LANG+set}" = set; then LANG=C; export LANG; fi - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -rf conftest* confdefs.h -# AIX cpp loses on an empty file, so make sure it contains at least a newline. -echo > confdefs.h - -# A filename unique to this package, relative to the directory that -# configure is in, which we can look for to find out if srcdir is correct. -ac_unique_file=initscan.c - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then its parent. - ac_prog=$0 - ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` - test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. - srcdir=$ac_confdir - if test ! -r $srcdir/$ac_unique_file; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r $srcdir/$ac_unique_file; then - if test "$ac_srcdir_defaulted" = yes; then - { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } - else - { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } - fi -fi -srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` - -# Prefer explicitly selected file to automatically selected ones. -if test -z "$CONFIG_SITE"; then - if test "x$prefix" != xNONE; then - CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" - else - CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" - fi -fi -for ac_site_file in $CONFIG_SITE; do - if test -r "$ac_site_file"; then - echo "loading site script $ac_site_file" - . "$ac_site_file" - fi -done - -if test -r "$cache_file"; then - echo "loading cache $cache_file" - . $cache_file -else - echo "creating cache $cache_file" - > $cache_file -fi - -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} $CFLAGS $CPPFLAGS conftest.$ac_ext -c 1>&5 2>&5' -ac_link='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext -o conftest $LIBS 1>&5 2>&5' - -if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then - # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. - if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then - ac_n= ac_c=' -' ac_t=' ' - else - ac_n=-n ac_c= ac_t= - fi -else - ac_n= ac_c='\c' ac_t= -fi - - - - -echo $ac_n "checking whether ln -s works""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_prog_LN_S'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - rm -f conftestdata -if ln -s X conftestdata 2>/dev/null -then - rm -f conftestdata - ac_cv_prog_LN_S="ln -s" -else - ac_cv_prog_LN_S=ln -fi -fi -LN_S="$ac_cv_prog_LN_S" -if test "$ac_cv_prog_LN_S" = "ln -s"; then - echo "$ac_t""yes" 1>&4 -else - echo "$ac_t""no" 1>&4 -fi - -for ac_prog in 'bison -y' byacc -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_prog_YACC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - if test -n "$YACC"; then - ac_cv_prog_YACC="$YACC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_YACC="$ac_prog" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -YACC="$ac_cv_prog_YACC" -if test -n "$YACC"; then - echo "$ac_t""$YACC" 1>&4 -else - echo "$ac_t""no" 1>&4 -fi - -test -n "$YACC" && break -done -test -n "$YACC" || YACC="yacc" - -# Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CC="gcc" - break - fi - done - IFS="$ac_save_ifs" - test -z "$ac_cv_prog_CC" && ac_cv_prog_CC="cc" -fi -fi -CC="$ac_cv_prog_CC" -if test -n "$CC"; then - echo "$ac_t""$CC" 1>&4 -else - echo "$ac_t""no" 1>&4 -fi - - -echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_prog_gcc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - cat > conftest.c <&5 | egrep yes >/dev/null 2>&1; then - ac_cv_prog_gcc=yes -else - ac_cv_prog_gcc=no -fi -fi -echo "$ac_t""$ac_cv_prog_gcc" 1>&4 -if test $ac_cv_prog_gcc = yes; then - GCC=yes - if test "${CFLAGS+set}" != set; then - echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_prog_gcc_g'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - echo 'void f(){}' > conftest.c -if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then - ac_cv_prog_gcc_g=yes -else - ac_cv_prog_gcc_g=no -fi -rm -f conftest* - -fi - echo "$ac_t""$ac_cv_prog_gcc_g" 1>&4 - if test $ac_cv_prog_gcc_g = yes; then - CFLAGS="-g -O" - else - CFLAGS="-O" - fi - fi -else - GCC= - test "${CFLAGS+set}" = set || CFLAGS="-g" -fi - -# Extract the first word of "ranlib", so it can be a program name with args. -set dummy ranlib; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_prog_RANLIB'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - if test -n "$RANLIB"; then - ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_RANLIB="ranlib" - break - fi - done - IFS="$ac_save_ifs" - test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" -fi -fi -RANLIB="$ac_cv_prog_RANLIB" -if test -n "$RANLIB"; then - echo "$ac_t""$RANLIB" 1>&4 -else - echo "$ac_t""no" 1>&4 -fi - -ac_aux_dir= -for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do - if test -f $ac_dir/install-sh; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install-sh -c" - break - elif test -f $ac_dir/install.sh; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install.sh -c" - break - fi -done -if test -z "$ac_aux_dir"; then - { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } -fi -ac_config_guess=$ac_aux_dir/config.guess -ac_config_sub=$ac_aux_dir/config.sub -ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. - -# Find a good install program. We prefer a C program (faster), -# so one script is as good as another. But avoid the broken or -# incompatible versions: -# SysV /etc/install, /usr/sbin/install -# SunOS /usr/etc/install -# IRIX /sbin/install -# AIX /bin/install -# AFS /usr/afsws/bin/install, which mishandles nonexistent args -# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" -# ./install, which can be erroneously created by make from ./install.sh. -echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&4 -if test -z "$INSTALL"; then -if eval "test \"`echo '${'ac_cv_path_install'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do - case "$ac_dir" in - ''|.|/etc|/usr/sbin|/usr/etc|/sbin|/usr/afsws/bin|/usr/ucb) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - for ac_prog in ginstall installbsd scoinst install; do - if test -f $ac_dir/$ac_prog; then - if test $ac_prog = install && - grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - # OSF/1 installbsd also uses dspmsg, but is usable. - : - else - ac_cv_path_install="$ac_dir/$ac_prog -c" - break 2 - fi - fi - done - ;; - esac - done - IFS="$ac_save_ifs" - # As a last resort, use the slow shell script. - test -z "$ac_cv_path_install" && ac_cv_path_install="$ac_install_sh" -fi - INSTALL="$ac_cv_path_install" -fi -echo "$ac_t""$INSTALL" 1>&4 - -# Use test -z because SunOS4 sh mishandles braces in ${var-val}. -# It thinks the first close brace ends the variable substitution. -test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' - -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' - -echo $ac_n "checking whether ${MAKE-make} sets \$MAKE""... $ac_c" 1>&4 -set dummy ${MAKE-make}; ac_make=$2 -if eval "test \"`echo '${'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - cat > conftestmake <<\EOF -all: - @echo 'ac_maketemp="${MAKE}"' -EOF -# GNU make sometimes prints "make[1]: Entering...", which would confuse us. -eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=` -if test -n "$ac_maketemp"; then - eval ac_cv_prog_make_${ac_make}_set=yes -else - eval ac_cv_prog_make_${ac_make}_set=no -fi -rm -f conftestmake -fi -if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then - echo "$ac_t""yes" 1>&4 - SET_MAKE= -else - echo "$ac_t""no" 1>&4 - SET_MAKE="MAKE=${MAKE-make}" -fi - -echo $ac_n "checking for working const""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_c_const'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - cat > conftest.$ac_ext <j = 5; -} -{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ - const int foo = 10; -} - -; return 0; } -EOF -if eval $ac_compile; then - rm -rf conftest* - ac_cv_c_const=yes -else - rm -rf conftest* - ac_cv_c_const=no -fi -rm -f conftest* - -fi -echo "$ac_t""$ac_cv_c_const" 1>&4 -if test $ac_cv_c_const = no; then - cat >> confdefs.h <<\EOF -#define const -EOF - -fi - -echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&4 -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then -if eval "test \"`echo '${'ac_cv_prog_CPP'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - # This must be in double quotes, not single quotes, because CPP may get - # substituted into the Makefile and "${CC-cc}" will confuse make. - CPP="${CC-cc} -E" - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. - cat > conftest.$ac_ext < -Syntax Error -EOF -eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - rm -rf conftest* - CPP="${CC-cc} -E -traditional-cpp" - cat > conftest.$ac_ext < -Syntax Error -EOF -eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - rm -rf conftest* - CPP=/lib/cpp -fi -rm -f conftest* -fi -rm -f conftest* - ac_cv_prog_CPP="$CPP" -fi -fi -CPP="$ac_cv_prog_CPP" -echo "$ac_t""$CPP" 1>&4 - -# If we cannot run a trivial program, we must be cross compiling. -echo $ac_n "checking whether cross-compiling""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_c_cross'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - if test "$cross_compiling" = yes; then - ac_cv_cross=yes -else -cat > conftest.$ac_ext </dev/null; then - ac_cv_c_cross=no -else - ac_cv_c_cross=yes -fi -fi -rm -fr conftest* -fi -cross_compiling=$ac_cv_c_cross -echo "$ac_t""$ac_cv_c_cross" 1>&4 - -echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_header_stdc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - cat > conftest.$ac_ext < -#include -#include -#include -EOF -eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - rm -rf conftest* - ac_cv_header_stdc=yes -else - echo "$ac_err" >&5 - rm -rf conftest* - ac_cv_header_stdc=no -fi -rm -f conftest* - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. -cat > conftest.$ac_ext < -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "memchr" >/dev/null 2>&1; then - : -else - rm -rf conftest* - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. -cat > conftest.$ac_ext < -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "free" >/dev/null 2>&1; then - : -else - rm -rf conftest* - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. -if test "$cross_compiling" = yes; then - ac_cv_header_stdc=no -else -cat > conftest.$ac_ext < -#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int main () { int i; for (i = 0; i < 256; i++) -if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); -exit (0); } - -EOF -eval $ac_link -if test -s conftest && (./conftest; exit) 2>/dev/null; then - : -else - ac_cv_header_stdc=no -fi -fi -rm -fr conftest* -fi -fi -echo "$ac_t""$ac_cv_header_stdc" 1>&4 -if test $ac_cv_header_stdc = yes; then - cat >> confdefs.h <<\EOF -#define STDC_HEADERS 1 -EOF - -fi - -echo $ac_n "checking for size_t""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_type_size_t'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - cat > conftest.$ac_ext < -#if STDC_HEADERS -#include -#endif -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "size_t" >/dev/null 2>&1; then - rm -rf conftest* - ac_cv_type_size_t=yes -else - rm -rf conftest* - ac_cv_type_size_t=no -fi -rm -f conftest* - -fi -echo "$ac_t""$ac_cv_type_size_t" 1>&4 -if test $ac_cv_type_size_t = no; then - cat >> confdefs.h <<\EOF -#define size_t unsigned -EOF - -fi - -echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_header_stdc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - cat > conftest.$ac_ext < -#include -#include -#include -EOF -eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - rm -rf conftest* - ac_cv_header_stdc=yes -else - echo "$ac_err" >&5 - rm -rf conftest* - ac_cv_header_stdc=no -fi -rm -f conftest* - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. -cat > conftest.$ac_ext < -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "memchr" >/dev/null 2>&1; then - : -else - rm -rf conftest* - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. -cat > conftest.$ac_ext < -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "free" >/dev/null 2>&1; then - : -else - rm -rf conftest* - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. -if test "$cross_compiling" = yes; then - ac_cv_header_stdc=no -else -cat > conftest.$ac_ext < -#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int main () { int i; for (i = 0; i < 256; i++) -if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); -exit (0); } - -EOF -eval $ac_link -if test -s conftest && (./conftest; exit) 2>/dev/null; then - : -else - ac_cv_header_stdc=no -fi -fi -rm -fr conftest* -fi -fi -echo "$ac_t""$ac_cv_header_stdc" 1>&4 -if test $ac_cv_header_stdc = yes; then - cat >> confdefs.h <<\EOF -#define STDC_HEADERS 1 -EOF - -fi - -for ac_hdr in string.h malloc.h sys/types.h -do -ac_safe=`echo "$ac_hdr" | tr './\055' '___'` -echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - cat > conftest.$ac_ext < -EOF -eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&4 - ac_tr_hdr=HAVE_`echo $ac_hdr | tr '[a-z]./\055' '[A-Z]___'` - cat >> confdefs.h <&4 -fi -done - - -case "$YACC" in -*bison*) - # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works -# for constant arguments. Useless! -echo $ac_n "checking for working alloca.h""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_header_alloca_h'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - cat > conftest.$ac_ext < -int main() { return 0; } -int t() { -char *p = alloca(2 * sizeof(int)); -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - ac_cv_header_alloca_h=yes -else - rm -rf conftest* - ac_cv_header_alloca_h=no -fi -rm -f conftest* - -fi -echo "$ac_t""$ac_cv_header_alloca_h" 1>&4 -if test $ac_cv_header_alloca_h = yes; then - cat >> confdefs.h <<\EOF -#define HAVE_ALLOCA_H 1 -EOF - -fi - -echo $ac_n "checking for alloca""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_func_alloca'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - cat > conftest.$ac_ext < -# else -# ifdef _AIX - #pragma alloca -# else -# ifndef alloca /* predefined by HP cc +Olibcalls */ -char *alloca (); -# endif -# endif -# endif -#endif - -int main() { return 0; } -int t() { -char *p = (char *) alloca(1); -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - ac_cv_func_alloca=yes -else - rm -rf conftest* - ac_cv_func_alloca=no -fi -rm -f conftest* - -fi -echo "$ac_t""$ac_cv_func_alloca" 1>&4 -if test $ac_cv_func_alloca = yes; then - cat >> confdefs.h <<\EOF -#define HAVE_ALLOCA 1 -EOF - -fi - -if test $ac_cv_func_alloca = no; then - # The SVR3 libPW and SVR4 libucb both contain incompatible functions - # that cause trouble. Some versions do not even contain alloca or - # contain a buggy version. If you still want to use their alloca, - # use ar to extract alloca.o from them instead of compiling alloca.c. - ALLOCA=alloca.o - cat >> confdefs.h <<\EOF -#define C_ALLOCA 1 -EOF - - -echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_os_cray'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - cat > conftest.$ac_ext <&5 | - egrep "webecray" >/dev/null 2>&1; then - rm -rf conftest* - ac_cv_os_cray=yes -else - rm -rf conftest* - ac_cv_os_cray=no -fi -rm -f conftest* - -fi -echo "$ac_t""$ac_cv_os_cray" 1>&4 -if test $ac_cv_os_cray = yes; then -echo $ac_n "checking for _getb67""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_func__getb67'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - cat > conftest.$ac_ext < /* Arbitrary system header to define __stub macros. */ -/* Override any gcc2 internal prototype to avoid an error. */ -char _getb67(); - -int main() { return 0; } -int t() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub__getb67) || defined (__stub____getb67) -choke me -#else -_getb67(); -#endif - -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - eval "ac_cv_func__getb67=yes" -else - rm -rf conftest* - eval "ac_cv_func__getb67=no" -fi -rm -f conftest* - -fi -if eval "test \"`echo '$ac_cv_func_'_getb67`\" = yes"; then - echo "$ac_t""yes" 1>&4 - cat >> confdefs.h <<\EOF -#define CRAY_STACKSEG_END _getb67 -EOF - -else - echo "$ac_t""no" 1>&4 -echo $ac_n "checking for GETB67""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_func_GETB67'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - cat > conftest.$ac_ext < /* Arbitrary system header to define __stub macros. */ -/* Override any gcc2 internal prototype to avoid an error. */ -char GETB67(); - -int main() { return 0; } -int t() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_GETB67) || defined (__stub___GETB67) -choke me -#else -GETB67(); -#endif - -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - eval "ac_cv_func_GETB67=yes" -else - rm -rf conftest* - eval "ac_cv_func_GETB67=no" -fi -rm -f conftest* - -fi -if eval "test \"`echo '$ac_cv_func_'GETB67`\" = yes"; then - echo "$ac_t""yes" 1>&4 - cat >> confdefs.h <<\EOF -#define CRAY_STACKSEG_END GETB67 -EOF - -else - echo "$ac_t""no" 1>&4 -echo $ac_n "checking for getb67""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_func_getb67'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - cat > conftest.$ac_ext < /* Arbitrary system header to define __stub macros. */ -/* Override any gcc2 internal prototype to avoid an error. */ -char getb67(); - -int main() { return 0; } -int t() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_getb67) || defined (__stub___getb67) -choke me -#else -getb67(); -#endif - -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - eval "ac_cv_func_getb67=yes" -else - rm -rf conftest* - eval "ac_cv_func_getb67=no" -fi -rm -f conftest* - -fi -if eval "test \"`echo '$ac_cv_func_'getb67`\" = yes"; then - echo "$ac_t""yes" 1>&4 - cat >> confdefs.h <<\EOF -#define CRAY_STACKSEG_END getb67 -EOF - -else - echo "$ac_t""no" 1>&4 -fi - -fi - -fi - -fi - -echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_c_stack_direction'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - if test "$cross_compiling" = yes; then - ac_cv_c_stack_direction=0 -else -cat > conftest.$ac_ext < addr) ? 1 : -1; -} -main () -{ - exit (find_stack_direction() < 0); -} -EOF -eval $ac_link -if test -s conftest && (./conftest; exit) 2>/dev/null; then - ac_cv_c_stack_direction=1 -else - ac_cv_c_stack_direction=-1 -fi -fi -rm -fr conftest* -fi -echo "$ac_t""$ac_cv_c_stack_direction" 1>&4 -cat >> confdefs.h < $cache_file <<\EOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs. It is not useful on other systems. -# If it contains results you don't want to keep, you may remove or edit it. -# -# By default, configure uses ./config.cache as the cache file, -# creating it if it does not exist already. You can give configure -# the --cache-file=FILE option to use a different cache file; that is -# what configure does when it calls configure scripts in -# subdirectories, so they share the cache. -# Giving --cache-file=/dev/null disables caching, for debugging configure. -# config.status only pays attention to the cache file if you give it the -# --recheck option to rerun configure. -# -EOF -# Ultrix sh set writes to stderr and can't be redirected directly. -(set) 2>&1 | - sed -n "s/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/: \${\1='\2'}/p" \ - >> $cache_file -else -echo "not updating unwritable cache $cache_file" -fi - -trap 'rm -fr conftest* confdefs* core $ac_clean_files; exit 1' 1 2 15 - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -# Any assignment to VPATH causes Sun make to only execute -# the first set of double-colon rules, so remove it if not needed. -# If there is a colon in the path, we need to keep it. -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' -fi - -trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 - -DEFS=-DHAVE_CONFIG_H - -# Without the "./", some shells look in PATH for config.status. -: ${CONFIG_STATUS=./config.status} - -echo creating $CONFIG_STATUS -rm -f $CONFIG_STATUS -cat > $CONFIG_STATUS </dev/null | sed 1q`: -# -# $0 $ac_configure_args -# -# Compiler output produced by configure, useful for debugging -# configure, is in ./config.log if it exists. - -ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" -for ac_option -do - case "\$ac_option" in - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" - exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; - -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.1" - exit 0 ;; - -help | --help | --hel | --he | --h) - echo "\$ac_cs_usage"; exit 0 ;; - *) echo "\$ac_cs_usage"; exit 1 ;; - esac -done - -ac_given_srcdir=$srcdir -ac_given_INSTALL="$INSTALL" - -trap 'rm -fr Makefile config.h:conf.in conftest*; exit 1' 1 2 15 - -# Protect against being on the right side of a sed subst in config.status. -sed 's/%@/@@/; s/@%/@@/; s/%g$/@g/; /@g$/s/[\\\\&%]/\\\\&/g; - s/@@/%@/; s/@@/@%/; s/@g$/%g/' > conftest.subs <<\CEOF -$ac_vpsub -$extrasub -s%@AR@%$AR%g -s%@CFLAGS@%$CFLAGS%g -s%@CPPFLAGS@%$CPPFLAGS%g -s%@CXXFLAGS@%$CXXFLAGS%g -s%@DEFS@%$DEFS%g -s%@LDFLAGS@%$LDFLAGS%g -s%@LIBS@%$LIBS%g -s%@exec_prefix@%$exec_prefix%g -s%@prefix@%$prefix%g -s%@program_transform_name@%$program_transform_name%g -s%@LN_S@%$LN_S%g -s%@YACC@%$YACC%g -s%@CC@%$CC%g -s%@RANLIB@%$RANLIB%g -s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g -s%@INSTALL_DATA@%$INSTALL_DATA%g -s%@SET_MAKE@%$SET_MAKE%g -s%@CPP@%$CPP%g -s%@ALLOCA@%$ALLOCA%g - -CEOF -EOF -cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF -for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then - # Support "outfile[:infile]", defaulting infile="outfile.in". - case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%.*:%%'` - ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - *) ac_file_in="${ac_file}.in" ;; - esac - - # Adjust relative srcdir, etc. for subdirectories. - - # Remove last slash and all that follows it. Not all systems have dirname. - ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` - if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then - # The file is in a subdirectory. - test ! -d "$ac_dir" && mkdir "$ac_dir" - ac_dir_suffix="/$ac_dir" - # A "../" for each directory in $ac_dir_suffix. - ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` - else - ac_dir_suffix= ac_dots= - fi - - case "$ac_given_srcdir" in - .) srcdir=. - if test -z "$ac_dots"; then top_srcdir=. - else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; - /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; - *) # Relative path. - srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" - top_srcdir="$ac_dots$ac_given_srcdir" ;; - esac - - case "$ac_given_INSTALL" in - [/$]*) INSTALL="$ac_given_INSTALL" ;; - *) INSTALL="$ac_dots$ac_given_INSTALL" ;; - esac - echo creating "$ac_file" - rm -f "$ac_file" - configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." - case "$ac_file" in - *Makefile*) ac_comsub="1i\\ -# $configure_input" ;; - *) ac_comsub= ;; - esac - sed -e "$ac_comsub -s%@configure_input@%$configure_input%g -s%@srcdir@%$srcdir%g -s%@top_srcdir@%$top_srcdir%g -s%@INSTALL@%$INSTALL%g -" -f conftest.subs $ac_given_srcdir/$ac_file_in > $ac_file -fi; done -rm -f conftest.subs - -# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where -# NAME is the cpp macro being defined and VALUE is the value it is being given. -# -# ac_d sets the value in "#define NAME VALUE" lines. -ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' -ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' -ac_dC='\3' -ac_dD='%g' -# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". -ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' -ac_uB='\([ ]\)%\1#\2define\3' -ac_uC=' ' -ac_uD='\4%g' -# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". -ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' -ac_eB='$%\1#\2define\3' -ac_eC=' ' -ac_eD='%g' - -CONFIG_HEADERS=${CONFIG_HEADERS-"config.h:conf.in"} -for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then - # Support "outfile[:infile]", defaulting infile="outfile.in". - case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%.*:%%'` - ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - *) ac_file_in="${ac_file}.in" ;; - esac - - echo creating $ac_file - - rm -f conftest.frag conftest.in conftest.out - cp $ac_given_srcdir/$ac_file_in conftest.in - -EOF - -# Transform confdefs.h into a sed script conftest.vals that substitutes -# the proper values into config.h.in to produce config.h. And first: -# Protect against being on the right side of a sed subst in config.status. -# Protect against being in an unquoted here document in config.status. -rm -f conftest.vals -cat > conftest.hdr <<\EOF -s/[\\&%]/\\&/g -s%[\\$`]%\\&%g -s%#define \([A-Za-z_][A-Za-z0-9_]*\) \(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp -s%ac_d%ac_u%gp -s%ac_u%ac_e%gp -EOF -sed -n -f conftest.hdr confdefs.h > conftest.vals -rm -f conftest.hdr - -# This sed command replaces #undef with comments. This is necessary, for -# example, in the case of _POSIX_SOURCE, which is predefined and required -# on some systems where configure will not decide to define it. -cat >> conftest.vals <<\EOF -s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */% -EOF - -# Break up conftest.vals because some shells have a limit on -# the size of here documents, and old seds have small limits too. -# Maximum number of lines to put in a single here document. -ac_max_here_lines=12 - -rm -f conftest.tail -while : -do - ac_lines=`grep -c . conftest.vals` - # grep -c gives empty output for an empty file on some AIX systems. - if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi - # Write a limited-size here document to conftest.frag. - echo ' cat > conftest.frag <> $CONFIG_STATUS - sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS - echo 'CEOF - sed -f conftest.frag conftest.in > conftest.out - rm -f conftest.in - mv conftest.out conftest.in -' >> $CONFIG_STATUS - sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail - rm -f conftest.vals - mv conftest.tail conftest.vals -done -rm -f conftest.vals - -cat >> $CONFIG_STATUS <<\EOF - rm -f conftest.frag conftest.h - echo "/* $ac_file. Generated automatically by configure. */" > conftest.h - cat conftest.in >> conftest.h - rm -f conftest.in - if cmp -s $ac_file conftest.h 2>/dev/null; then - echo "$ac_file is unchanged" - rm -f conftest.h - else - rm -f $ac_file - mv conftest.h $ac_file - fi -fi; done - - -test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h -exit 0 -EOF -chmod +x $CONFIG_STATUS -rm -fr confdefs* $ac_clean_files -test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS - diff --git a/commands/flex-2.5.4/configure.in b/commands/flex-2.5.4/configure.in deleted file mode 100644 index eecd5a9a3..000000000 --- a/commands/flex-2.5.4/configure.in +++ /dev/null @@ -1,29 +0,0 @@ -dnl Process this file with autoconf to produce a configure script. -dnl -AC_INIT(initscan.c) -AC_CONFIG_HEADER(config.h:conf.in) - -AC_LN_S -AC_PROG_YACC -AC_PROG_CC -AC_PROG_RANLIB -AC_PROG_INSTALL -AC_PROG_MAKE_SET -AC_CHECK_PROG(AR, ar, , ar) -AC_CONST -AC_TYPE_SIZE_T -AC_HEADER_STDC -AC_HAVE_HEADERS(string.h malloc.h sys/types.h) - -case "$YACC" in -*bison*) - AC_ALLOCA - ;; -esac - -AC_OUTPUT(Makefile, -[test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h]) - -AC_SUBST(AR) -AC_SUBST(ARFLAGS) - diff --git a/commands/flex-2.5.4/configure.minix b/commands/flex-2.5.4/configure.minix deleted file mode 100755 index 9c4da93e8..000000000 --- a/commands/flex-2.5.4/configure.minix +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./configure --prefix=/usr diff --git a/commands/flex-2.5.4/install.sh b/commands/flex-2.5.4/install.sh deleted file mode 100755 index 0ff4b6a08..000000000 --- a/commands/flex-2.5.4/install.sh +++ /dev/null @@ -1,119 +0,0 @@ -#!/bin/sh - -# -# install - install a program, script, or datafile -# This comes from X11R5; it is not part of GNU. -# -# $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $ -# -# This script is compatible with the BSD install script, but was written -# from scratch. -# - - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" - - -# put in absolute paths if you don't have them in your path; or use env. vars. - -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" - -instcmd="$mvprog" -chmodcmd="" -chowncmd="" -chgrpcmd="" -stripcmd="" -rmcmd="$rmprog -f" -mvcmd="$mvprog" -src="" -dst="" - -while [ x"$1" != x ]; do - case $1 in - -c) instcmd="$cpprog" - shift - continue;; - - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - -s) stripcmd="$stripprog" - shift - continue;; - - *) if [ x"$src" = x ] - then - src=$1 - else - dst=$1 - fi - shift - continue;; - esac -done - -if [ x"$src" = x ] -then - echo "install: no input file specified" - exit 1 -fi - -if [ x"$dst" = x ] -then - echo "install: no destination specified" - exit 1 -fi - - -# If destination is a directory, append the input filename; if your system -# does not like double slashes in filenames, you may need to add some logic - -if [ -d $dst ] -then - dst="$dst"/`basename $src` -fi - -# Make a temp file name in the proper directory. - -dstdir=`dirname $dst` -dsttmp=$dstdir/#inst.$$# - -# Move or copy the file name to the temp name - -$doit $instcmd $src $dsttmp - -# and set any options; do chmod last to preserve setuid bits - -if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; fi -if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; fi -if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; fi -if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; fi - -# Now rename the file to the real destination. - -$doit $rmcmd $dst -$doit $mvcmd $dsttmp $dst - - -exit 0 diff --git a/commands/flex-2.5.4/mkinstalldirs b/commands/flex-2.5.4/mkinstalldirs deleted file mode 100755 index 0e2937731..000000000 --- a/commands/flex-2.5.4/mkinstalldirs +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -# Make directory hierarchy. -# Written by Noah Friedman -# Public domain. - -defaultIFS=' -' -IFS="${IFS-${defaultIFS}}" - -errstatus=0 - -for file in ${1+"$@"} ; do - oIFS="${IFS}" - # Some sh's can't handle IFS=/ for some reason. - IFS='%' - set - `echo ${file} | sed -e 's@/@%@g' -e 's@^%@/@'` - IFS="${oIFS}" - - pathcomp='' - - for d in ${1+"$@"} ; do - pathcomp="${pathcomp}${d}" - - if test ! -d "${pathcomp}"; then - echo "mkdir $pathcomp" 1>&2 - mkdir "${pathcomp}" || errstatus=$? - fi - - pathcomp="${pathcomp}/" - done -done - -exit $errstatus - -# eof diff --git a/commands/flex-2.5.4/skel.c b/commands/flex-2.5.4/skel.c deleted file mode 100644 index 4ee481bb5..000000000 --- a/commands/flex-2.5.4/skel.c +++ /dev/null @@ -1,1548 +0,0 @@ -/* File created from flex.skl via mkskel.sh */ - -#include "flexdef.h" - -const char *skel[] = { - "/* A lexical scanner generated by flex */", - "", - "/* Scanner skeleton version:", - " * $Header$", - " */", - "", - "#define FLEX_SCANNER", - "#define YY_FLEX_MAJOR_VERSION 2", - "#define YY_FLEX_MINOR_VERSION 5", - "", - "%-", - "#include ", - "%*", - "", - "", - "/* cfront 1.2 defines \"c_plusplus\" instead of \"__cplusplus\" */", - "#ifdef c_plusplus", - "#ifndef __cplusplus", - "#define __cplusplus", - "#endif", - "#endif", - "", - "", - "#ifdef __cplusplus", - "", - "#include ", - "%+", - "class istream;", - "%*", - "#include ", - "", - "/* Use prototypes in function declarations. */", - "#define YY_USE_PROTOS", - "", - "/* The \"const\" storage-class-modifier is valid. */", - "#define YY_USE_CONST", - "", - "#else /* ! __cplusplus */", - "", - "#if __STDC__", - "", - "#define YY_USE_PROTOS", - "#define YY_USE_CONST", - "", - "#endif /* __STDC__ */", - "#endif /* ! __cplusplus */", - "", - "#ifdef __TURBOC__", - " #pragma warn -rch", - " #pragma warn -use", - "#include ", - "#include ", - "#define YY_USE_CONST", - "#define YY_USE_PROTOS", - "#endif", - "", - "#ifdef YY_USE_CONST", - "#define yyconst const", - "#else", - "#define yyconst", - "#endif", - "", - "", - "#ifdef YY_USE_PROTOS", - "#define YY_PROTO(proto) proto", - "#else", - "#define YY_PROTO(proto) ()", - "#endif", - "", - "/* Returned upon end-of-file. */", - "#define YY_NULL 0", - "", - "/* Promotes a possibly negative, possibly signed char to an unsigned", - " * integer for use as an array index. If the signed char is negative,", - " * we want to instead treat it as an 8-bit unsigned char, hence the", - " * double cast.", - " */", - "#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)", - "", - "/* Enter a start condition. This macro really ought to take a parameter,", - " * but we do it the disgusting crufty way forced on us by the ()-less", - " * definition of BEGIN.", - " */", - "#define BEGIN yy_start = 1 + 2 *", - "", - "/* Translate the current start state into a value that can be later handed", - " * to BEGIN to return to the state. The YYSTATE alias is for lex", - " * compatibility.", - " */", - "#define YY_START ((yy_start - 1) / 2)", - "#define YYSTATE YY_START", - "", - "/* Action number for EOF rule of a given start state. */", - "#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)", - "", - "/* Special action meaning \"start processing a new file\". */", - "#define YY_NEW_FILE yyrestart( yyin )", - "", - "#define YY_END_OF_BUFFER_CHAR 0", - "", - "/* Size of default input buffer. */", - "#define YY_BUF_SIZE 16384", - "", - "typedef struct yy_buffer_state *YY_BUFFER_STATE;", - "", - "extern int yyleng;", - "%-", - "extern FILE *yyin, *yyout;", - "%*", - "", - "#define EOB_ACT_CONTINUE_SCAN 0", - "#define EOB_ACT_END_OF_FILE 1", - "#define EOB_ACT_LAST_MATCH 2", - "", - "/* The funky do-while in the following #define is used to turn the definition", - " * int a single C statement (which needs a semi-colon terminator). This", - " * avoids problems with code like:", - " *", - " * if ( condition_holds )", - " * yyless( 5 );", - " * else", - " * do_something_else();", - " *", - " * Prior to using the do-while the compiler would get upset at the", - " * \"else\" because it interpreted the \"if\" statement as being all", - " * done when it reached the ';' after the yyless() call.", - " */", - "", - "/* Return all but the first 'n' matched characters back to the input stream. */", - "", - "#define yyless(n) \\", - " do \\", - " { \\", - " /* 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 */ \\", - " } \\", - " while ( 0 )", - "", - "#define unput(c) yyunput( c, yytext_ptr )", - "", - "/* The following is because we cannot portably get our hands on size_t", - " * (without autoconf's help, which isn't available because we want", - " * flex-generated scanners to compile on their own).", - " */", - "typedef unsigned int yy_size_t;", - "", - "", - "struct yy_buffer_state", - " {", - "%-", - " FILE *yy_input_file;", - "%+", - " istream* yy_input_file;", - "%*", - "", - " char *yy_ch_buf; /* input buffer */", - " char *yy_buf_pos; /* current position in input buffer */", - "", - " /* Size of input buffer in bytes, not including room for EOB", - " * characters.", - " */", - " yy_size_t yy_buf_size;", - "", - " /* Number of characters read into yy_ch_buf, not including EOB", - " * characters.", - " */", - " int yy_n_chars;", - "", - " /* Whether we \"own\" the buffer - i.e., we know we created it,", - " * and can realloc() it to grow it, and should free() it to", - " * delete it.", - " */", - " int yy_is_our_buffer;", - "", - " /* Whether this is an \"interactive\" input source; if so, and", - " * if we're using stdio for input, then we want to use getc()", - " * instead of fread(), to make sure we stop fetching input after", - " * each newline.", - " */", - " int yy_is_interactive;", - "", - " /* Whether we're considered to be at the beginning of a line.", - " * If so, '^' rules will be active on the next match, otherwise", - " * not.", - " */", - " int yy_at_bol;", - "", - " /* Whether to try to fill the input buffer when we reach the", - " * end of it.", - " */", - " int yy_fill_buffer;", - "", - " int yy_buffer_status;", - "#define YY_BUFFER_NEW 0", - "#define YY_BUFFER_NORMAL 1", - " /* When an EOF's been seen but there's still some text to process", - " * then we mark the buffer as YY_EOF_PENDING, to indicate that we", - " * shouldn't try reading from the input source any more. We might", - " * still have a bunch of tokens to match, though, because of", - " * possible backing-up.", - " *", - " * When we actually see the EOF, we change the status to \"new\"", - " * (via yyrestart()), so that the user can continue scanning by", - " * just pointing yyin at a new input file.", - " */", - "#define YY_BUFFER_EOF_PENDING 2", - " };", - "", - "%- Standard (non-C++) definition", - "static YY_BUFFER_STATE yy_current_buffer = 0;", - "%*", - "", - "/* We provide macros for accessing buffer states in case in the", - " * future we want to put the buffer states in a more general", - " * \"scanner state\".", - " */", - "#define YY_CURRENT_BUFFER yy_current_buffer", - "", - "", - "%- Standard (non-C++) definition", - "/* yy_hold_char holds the character lost when yytext is formed. */", - "static char yy_hold_char;", - "", - "static int yy_n_chars; /* number of characters read into yy_ch_buf */", - "", - "", - "int yyleng;", - "", - "/* Points to current character in buffer. */", - "static char *yy_c_buf_p = (char *) 0;", - "static int yy_init = 1; /* whether we need to initialize */", - "static int yy_start = 0; /* start state number */", - "", - "/* Flag which is used to allow yywrap()'s to do buffer switches", - " * instead of setting up a fresh yyin. A bit of a hack ...", - " */", - "static int yy_did_buffer_switch_on_eof;", - "", - "void yyrestart YY_PROTO(( FILE *input_file ));", - "", - "void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));", - "void yy_load_buffer_state YY_PROTO(( void ));", - "YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));", - "void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));", - "void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));", - "void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));", - "#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 *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 ));", - "static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));", - "static void yy_flex_free YY_PROTO(( void * ));", - "", - "#define yy_new_buffer yy_create_buffer", - "", - "#define yy_set_interactive(is_interactive) \\", - " { \\", - " if ( ! yy_current_buffer ) \\", - " yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \\", - " yy_current_buffer->yy_is_interactive = is_interactive; \\", - " }", - "", - "#define yy_set_bol(at_bol) \\", - " { \\", - " if ( ! yy_current_buffer ) \\", - " yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \\", - " yy_current_buffer->yy_at_bol = at_bol; \\", - " }", - "", - "#define YY_AT_BOL() (yy_current_buffer->yy_at_bol)", - "", - "%% yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here", - "", - "%- Standard (non-C++) definition", - "static yy_state_type yy_get_previous_state YY_PROTO(( void ));", - "static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));", - "static int yy_get_next_buffer YY_PROTO(( void ));", - "static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));", - "%*", - "", - "/* Done after the current pattern has been matched and before the", - " * corresponding action - sets up yytext.", - " */", - "#define YY_DO_BEFORE_ACTION \\", - " yytext_ptr = yy_bp; \\", - "%% code to fiddle yytext and yyleng for yymore() goes here", - " yy_hold_char = *yy_cp; \\", - " *yy_cp = '\\0'; \\", - "%% code to copy yytext_ptr to yytext[] goes here, if %array", - " yy_c_buf_p = yy_cp;", - "", - "%% data tables for the DFA and the user's section 1 definitions go here", - "", - "/* Macros after this point can all be overridden by user definitions in", - " * section 1.", - " */", - "", - "#ifndef YY_SKIP_YYWRAP", - "#ifdef __cplusplus", - "extern \"C\" int yywrap YY_PROTO(( void ));", - "#else", - "extern int yywrap YY_PROTO(( void ));", - "#endif", - "#endif", - "", - "%-", - "#ifndef YY_NO_UNPUT", - "static void yyunput YY_PROTO(( int c, char *buf_ptr ));", - "#endif", - "%*", - "", - "#ifndef yytext_ptr", - "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", - "%- Standard (non-C++) definition", - "#ifdef __cplusplus", - "static int yyinput YY_PROTO(( void ));", - "#else", - "static int input YY_PROTO(( void ));", - "#endif", - "%*", - "#endif", - "", - "#if YY_STACK_USED", - "static int yy_start_stack_ptr = 0;", - "static int yy_start_stack_depth = 0;", - "static int *yy_start_stack = 0;", - "#ifndef YY_NO_PUSH_STATE", - "static void yy_push_state YY_PROTO(( int new_state ));", - "#endif", - "#ifndef YY_NO_POP_STATE", - "static void yy_pop_state YY_PROTO(( void ));", - "#endif", - "#ifndef YY_NO_TOP_STATE", - "static int yy_top_state YY_PROTO(( void ));", - "#endif", - "", - "#else", - "#define YY_NO_PUSH_STATE 1", - "#define YY_NO_POP_STATE 1", - "#define YY_NO_TOP_STATE 1", - "#endif", - "", - "#ifdef YY_MALLOC_DECL", - "YY_MALLOC_DECL", - "#else", - "#if __STDC__", - "#ifndef __cplusplus", - "#include ", - "#endif", - "#else", - "/* Just try to get by without declaring the routines. This will fail", - " * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)", - " * or sizeof(void*) != sizeof(int).", - " */", - "#endif", - "#endif", - "", - "/* Amount of stuff to slurp up with each read. */", - "#ifndef YY_READ_BUF_SIZE", - "#define YY_READ_BUF_SIZE 8192", - "#endif", - "", - "/* Copy whatever the last rule matched to the standard output. */", - "", - "#ifndef ECHO", - "%- Standard (non-C++) definition", - "/* This used to be an fputs(), but since the string might contain NUL's,", - " * we now use fwrite().", - " */", - "#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )", - "%+ C++ definition", - "#define ECHO LexerOutput( yytext, yyleng )", - "%*", - "#endif", - "", - "/* Gets input and stuffs it into \"buf\". number of characters read, or YY_NULL,", - " * is returned in \"result\".", - " */", - "#ifndef YY_INPUT", - "#define YY_INPUT(buf,result,max_size) \\", - "%% fread()/read() definition of YY_INPUT goes here unless we're doing C++", - "%+ C++ definition", - " if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \\", - " YY_FATAL_ERROR( \"input in flex scanner failed\" );", - "%*", - "#endif", - "", - "/* No semi-colon after return; correct usage is to write \"yyterminate();\" -", - " * we don't want an extra ';' after the \"return\" because that will cause", - " * some compilers to complain about unreachable statements.", - " */", - "#ifndef yyterminate", - "#define yyterminate() return YY_NULL", - "#endif", - "", - "/* Number of entries by which start-condition stack grows. */", - "#ifndef YY_START_STACK_INCR", - "#define YY_START_STACK_INCR 25", - "#endif", - "", - "/* Report a fatal error. */", - "#ifndef YY_FATAL_ERROR", - "%-", - "#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )", - "%+", - "#define YY_FATAL_ERROR(msg) LexerError( msg )", - "%*", - "#endif", - "", - "/* Default declaration of generated scanner - a define so the user can", - " * easily add parameters.", - " */", - "#ifndef YY_DECL", - "%- Standard (non-C++) definition", - "#define YY_DECL int yylex YY_PROTO(( void ))", - "%+ C++ definition", - "#define YY_DECL int yyFlexLexer::yylex()", - "%*", - "#endif", - "", - "/* Code executed at the beginning of each rule, after yytext and yyleng", - " * have been set up.", - " */", - "#ifndef YY_USER_ACTION", - "#define YY_USER_ACTION", - "#endif", - "", - "/* Code executed at the end of each rule. */", - "#ifndef YY_BREAK", - "#define YY_BREAK break;", - "#endif", - "", - "%% YY_RULE_SETUP definition goes here", - "", - "YY_DECL", - " {", - " register yy_state_type yy_current_state;", - " register char *yy_cp, *yy_bp;", - " register int yy_act;", - "", - "%% user's declarations go here", - "", - " if ( yy_init )", - " {", - " yy_init = 0;", - "", - "#ifdef YY_USER_INIT", - " YY_USER_INIT;", - "#endif", - "", - " if ( ! yy_start )", - " yy_start = 1; /* first start state */", - "", - " if ( ! yyin )", - "%-", - " yyin = stdin;", - "%+", - " yyin = &cin;", - "%*", - "", - " if ( ! yyout )", - "%-", - " yyout = stdout;", - "%+", - " yyout = &cout;", - "%*", - "", - " if ( ! yy_current_buffer )", - " yy_current_buffer =", - " yy_create_buffer( yyin, YY_BUF_SIZE );", - "", - " yy_load_buffer_state();", - " }", - "", - " while ( 1 ) /* loops until end-of-file is reached */", - " {", - "%% yymore()-related code goes here", - " yy_cp = yy_c_buf_p;", - "", - " /* Support of yytext. */", - " *yy_cp = yy_hold_char;", - "", - " /* yy_bp points to the position in yy_ch_buf of the start of", - " * the current run.", - " */", - " yy_bp = yy_cp;", - "", - "%% code to set up and find next match goes here", - "", - "yy_find_action:", - "%% code to find the action number goes here", - "", - " YY_DO_BEFORE_ACTION;", - "", - "%% code for yylineno update goes here", - "", - "do_action: /* This label is used only to access EOF actions. */", - "", - "%% debug code goes here", - "", - " switch ( yy_act )", - " { /* beginning of action switch */", - "%% actions go here", - "", - " case YY_END_OF_BUFFER:", - " {", - " /* Amount of text matched not including the EOB char. */", - " int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;", - "", - " /* 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 )", - " {", - " /* We're scanning a new file or input source. It's", - " * possible that this happened because the user", - " * just pointed yyin at a new source and called", - " * yylex(). If so, then we have to assure", - " * consistency between yy_current_buffer and our", - " * globals. Here is the right place to do so, because", - " * this is the first action (other than possibly a", - " * back-up) that will match for the new input source.", - " */", - " yy_n_chars = yy_current_buffer->yy_n_chars;", - " yy_current_buffer->yy_input_file = yyin;", - " yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;", - " }", - "", - " /* Note that here we test for yy_c_buf_p \"<=\" to the position", - " * of the first EOB in the buffer, since yy_c_buf_p will", - " * already have been incremented past the NUL character", - " * (since all states make transitions on EOB to the", - " * end-of-buffer state). Contrast this with the test", - " * in input().", - " */", - " if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )", - " { /* This was really a NUL. */", - " yy_state_type yy_next_state;", - "", - " yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;", - "", - " yy_current_state = yy_get_previous_state();", - "", - " /* Okay, we're now positioned to make the NUL", - " * transition. We couldn't have", - " * yy_get_previous_state() go ahead and do it", - " * for us because it doesn't know how to deal", - " * with the possibility of jamming (and we don't", - " * want to build jamming into it because then it", - " * will run more slowly).", - " */", - "", - " yy_next_state = yy_try_NUL_trans( yy_current_state );", - "", - " yy_bp = yytext_ptr + YY_MORE_ADJ;", - "", - " if ( yy_next_state )", - " {", - " /* Consume the NUL. */", - " yy_cp = ++yy_c_buf_p;", - " yy_current_state = yy_next_state;", - " goto yy_match;", - " }", - "", - " else", - " {", - "%% code to do back-up for compressed tables and set up yy_cp goes here", - " goto yy_find_action;", - " }", - " }", - "", - " else switch ( yy_get_next_buffer() )", - " {", - " case EOB_ACT_END_OF_FILE:", - " {", - " yy_did_buffer_switch_on_eof = 0;", - "", - " if ( yywrap() )", - " {", - " /* Note: because we've taken care in", - " * yy_get_next_buffer() to have set up", - " * yytext, we can now set up", - " * yy_c_buf_p so that if some total", - " * hoser (like flex itself) wants to", - " * call the scanner after we return the", - " * YY_NULL, it'll still work - another", - " * YY_NULL will get returned.", - " */", - " yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;", - "", - " yy_act = YY_STATE_EOF(YY_START);", - " goto do_action;", - " }", - "", - " else", - " {", - " if ( ! yy_did_buffer_switch_on_eof )", - " YY_NEW_FILE;", - " }", - " break;", - " }", - "", - " case EOB_ACT_CONTINUE_SCAN:", - " yy_c_buf_p =", - " yytext_ptr + yy_amount_of_matched_text;", - "", - " yy_current_state = yy_get_previous_state();", - "", - " yy_cp = yy_c_buf_p;", - " yy_bp = yytext_ptr + YY_MORE_ADJ;", - " goto yy_match;", - "", - " case EOB_ACT_LAST_MATCH:", - " yy_c_buf_p =", - " &yy_current_buffer->yy_ch_buf[yy_n_chars];", - "", - " yy_current_state = yy_get_previous_state();", - "", - " yy_cp = yy_c_buf_p;", - " yy_bp = yytext_ptr + YY_MORE_ADJ;", - " goto yy_find_action;", - " }", - " break;", - " }", - "", - " default:", - " YY_FATAL_ERROR(", - " \"fatal flex scanner internal error--no action found\" );", - " } /* end of action switch */", - " } /* end of scanning one token */", - " } /* end of yylex */", - "", - "%+", - "yyFlexLexer::yyFlexLexer( istream* arg_yyin, ostream* arg_yyout )", - " {", - " yyin = arg_yyin;", - " yyout = arg_yyout;", - " yy_c_buf_p = 0;", - " yy_init = 1;", - " yy_start = 0;", - " yy_flex_debug = 0;", - " yylineno = 1; // this will only get updated if %option yylineno", - "", - " yy_did_buffer_switch_on_eof = 0;", - "", - " yy_looking_for_trail_begin = 0;", - " yy_more_flag = 0;", - " yy_more_len = 0;", - " yy_more_offset = yy_prev_more_offset = 0;", - "", - " yy_start_stack_ptr = yy_start_stack_depth = 0;", - " yy_start_stack = 0;", - "", - " yy_current_buffer = 0;", - "", - "#ifdef YY_USES_REJECT", - " yy_state_buf = new yy_state_type[YY_BUF_SIZE + 2];", - "#else", - " yy_state_buf = 0;", - "#endif", - " }", - "", - "yyFlexLexer::~yyFlexLexer()", - " {", - " delete yy_state_buf;", - " yy_delete_buffer( yy_current_buffer );", - " }", - "", - "void yyFlexLexer::switch_streams( istream* new_in, ostream* new_out )", - " {", - " if ( new_in )", - " {", - " yy_delete_buffer( yy_current_buffer );", - " yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) );", - " }", - "", - " if ( new_out )", - " yyout = new_out;", - " }", - "", - "#ifdef YY_INTERACTIVE", - "int yyFlexLexer::LexerInput( char* buf, int /* max_size */ )", - "#else", - "int yyFlexLexer::LexerInput( char* buf, int max_size )", - "#endif", - " {", - " if ( yyin->eof() || yyin->fail() )", - " return 0;", - "", - "#ifdef YY_INTERACTIVE", - " yyin->get( buf[0] );", - "", - " if ( yyin->eof() )", - " return 0;", - "", - " if ( yyin->bad() )", - " return -1;", - "", - " return 1;", - "", - "#else", - " (void) yyin->read( buf, max_size );", - "", - " if ( yyin->bad() )", - " return -1;", - " else", - " return yyin->gcount();", - "#endif", - " }", - "", - "void yyFlexLexer::LexerOutput( const char* buf, int size )", - " {", - " (void) yyout->write( buf, size );", - " }", - "%*", - "", - "/* yy_get_next_buffer - try to read in a new buffer", - " *", - " * Returns a code representing an action:", - " * EOB_ACT_LAST_MATCH -", - " * EOB_ACT_CONTINUE_SCAN - continue scanning from current position", - " * EOB_ACT_END_OF_FILE - end of file", - " */", - "", - "%-", - "static int yy_get_next_buffer()", - "%+", - "int yyFlexLexer::yy_get_next_buffer()", - "%*", - " {", - " register char *dest = yy_current_buffer->yy_ch_buf;", - " register char *source = yytext_ptr;", - " register int number_to_move, i;", - " int ret_val;", - "", - " if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )", - " YY_FATAL_ERROR(", - " \"fatal flex scanner internal error--end of buffer missed\" );", - "", - " if ( yy_current_buffer->yy_fill_buffer == 0 )", - " { /* 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 single character, the EOB, so", - " * treat this as a final EOF.", - " */", - " return EOB_ACT_END_OF_FILE;", - " }", - "", - " else", - " {", - " /* We matched some text prior to the EOB, first", - " * process it.", - " */", - " return EOB_ACT_LAST_MATCH;", - " }", - " }", - "", - " /* Try to read more data. */", - "", - " /* First move last chars to start of buffer. */", - " number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;", - "", - " for ( i = 0; i < number_to_move; ++i )", - " *(dest++) = *(source++);", - "", - " if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )", - " /* don't do the read, it's not guaranteed to return an EOF,", - " * just force an EOF", - " */", - " yy_current_buffer->yy_n_chars = yy_n_chars = 0;", - "", - " else", - " {", - " int num_to_read =", - " yy_current_buffer->yy_buf_size - number_to_move - 1;", - "", - " while ( num_to_read <= 0 )", - " { /* Not enough room in the buffer - grow it. */", - "#ifdef YY_USES_REJECT", - " YY_FATAL_ERROR(", - "\"input buffer overflow, can't enlarge buffer because scanner uses REJECT\" );", - "#else", - "", - " /* just a shorter name for the current buffer */", - " YY_BUFFER_STATE b = yy_current_buffer;", - "", - " int yy_c_buf_p_offset =", - " (int) (yy_c_buf_p - b->yy_ch_buf);", - "", - " if ( b->yy_is_our_buffer )", - " {", - " int new_size = b->yy_buf_size * 2;", - "", - " if ( new_size <= 0 )", - " b->yy_buf_size += b->yy_buf_size / 8;", - " else", - " b->yy_buf_size *= 2;", - "", - " b->yy_ch_buf = (char *)", - " /* Include room in for 2 EOB chars. */", - " yy_flex_realloc( (void *) b->yy_ch_buf,", - " b->yy_buf_size + 2 );", - " }", - " else", - " /* Can't grow it, we don't own it. */", - " b->yy_ch_buf = 0;", - "", - " if ( ! b->yy_ch_buf )", - " YY_FATAL_ERROR(", - " \"fatal error - scanner input buffer overflow\" );", - "", - " yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];", - "", - " num_to_read = yy_current_buffer->yy_buf_size -", - " number_to_move - 1;", - "#endif", - " }", - "", - " if ( num_to_read > YY_READ_BUF_SIZE )", - " num_to_read = YY_READ_BUF_SIZE;", - "", - " /* 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 )", - " {", - " if ( number_to_move == YY_MORE_ADJ )", - " {", - " ret_val = EOB_ACT_END_OF_FILE;", - " yyrestart( yyin );", - " }", - "", - " else", - " {", - " ret_val = EOB_ACT_LAST_MATCH;", - " yy_current_buffer->yy_buffer_status =", - " YY_BUFFER_EOF_PENDING;", - " }", - " }", - "", - " else", - " ret_val = EOB_ACT_CONTINUE_SCAN;", - "", - " yy_n_chars += number_to_move;", - " yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;", - " yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;", - "", - " yytext_ptr = &yy_current_buffer->yy_ch_buf[0];", - "", - " return ret_val;", - " }", - "", - "", - "/* yy_get_previous_state - get the state just before the EOB char was reached */", - "", - "%-", - "static yy_state_type yy_get_previous_state()", - "%+", - "yy_state_type yyFlexLexer::yy_get_previous_state()", - "%*", - " {", - " register yy_state_type yy_current_state;", - " register char *yy_cp;", - "", - "%% code to get the start state into yy_current_state goes here", - "", - " for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )", - " {", - "%% code to find the next state goes here", - " }", - "", - " return yy_current_state;", - " }", - "", - "", - "/* yy_try_NUL_trans - try to make a transition on the NUL character", - " *", - " * synopsis", - " * next_state = yy_try_NUL_trans( current_state );", - " */", - "", - "%-", - "#ifdef YY_USE_PROTOS", - "static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )", - "#else", - "static yy_state_type yy_try_NUL_trans( yy_current_state )", - "yy_state_type yy_current_state;", - "#endif", - "%+", - "yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state )", - "%*", - " {", - " register int yy_is_jam;", - "%% code to find the next state, and perhaps do backing up, goes here", - "", - " return yy_is_jam ? 0 : yy_current_state;", - " }", - "", - "", - "%-", - "#ifndef YY_NO_UNPUT", - "#ifdef YY_USE_PROTOS", - "static void yyunput( int c, register char *yy_bp )", - "#else", - "static void yyunput( c, yy_bp )", - "int c;", - "register char *yy_bp;", - "#endif", - "%+", - "void yyFlexLexer::yyunput( int c, register char* yy_bp )", - "%*", - " {", - " register char *yy_cp = yy_c_buf_p;", - "", - " /* undo effects of setting up yytext */", - " *yy_cp = yy_hold_char;", - "", - " if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )", - " { /* need to shift things up to make room */", - " /* +2 for EOB chars. */", - " register int number_to_move = yy_n_chars + 2;", - " register char *dest = &yy_current_buffer->yy_ch_buf[", - " yy_current_buffer->yy_buf_size + 2];", - " register char *source =", - " &yy_current_buffer->yy_ch_buf[number_to_move];", - "", - " while ( source > yy_current_buffer->yy_ch_buf )", - " *--dest = *--source;", - "", - " yy_cp += (int) (dest - source);", - " yy_bp += (int) (dest - source);", - " 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\" );", - " }", - "", - " *--yy_cp = (char) c;", - "", - "%% update yylineno here", - "", - " yytext_ptr = yy_bp;", - " yy_hold_char = *yy_cp;", - " yy_c_buf_p = yy_cp;", - " }", - "%-", - "#endif /* ifndef YY_NO_UNPUT */", - "%*", - "", - "", - "%-", - "#ifdef __cplusplus", - "static int yyinput()", - "#else", - "static int input()", - "#endif", - "%+", - "int yyFlexLexer::yyinput()", - "%*", - " {", - " int c;", - "", - " *yy_c_buf_p = yy_hold_char;", - "", - " if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )", - " {", - " /* yy_c_buf_p now points to the character we want to return.", - " * If this occurs *before* the EOB characters, then it's a", - " * valid NUL; if not, then we've hit the end of the buffer.", - " */", - " if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )", - " /* This was really a NUL. */", - " *yy_c_buf_p = '\\0';", - "", - " else", - " { /* need more input */", - " 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() )", - " return EOF;", - "", - " if ( ! yy_did_buffer_switch_on_eof )", - " YY_NEW_FILE;", - "#ifdef __cplusplus", - " return yyinput();", - "#else", - " return input();", - "#endif", - " }", - "", - " case EOB_ACT_CONTINUE_SCAN:", - " yy_c_buf_p = yytext_ptr + offset;", - " break;", - " }", - " }", - " }", - "", - " c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */", - " *yy_c_buf_p = '\\0'; /* preserve yytext */", - " yy_hold_char = *++yy_c_buf_p;", - "", - "%% update BOL and yylineno", - "", - " return c;", - " }", - "", - "", - "%-", - "#ifdef YY_USE_PROTOS", - "void yyrestart( FILE *input_file )", - "#else", - "void yyrestart( input_file )", - "FILE *input_file;", - "#endif", - "%+", - "void yyFlexLexer::yyrestart( istream* input_file )", - "%*", - " {", - " if ( ! yy_current_buffer )", - " yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );", - "", - " yy_init_buffer( yy_current_buffer, input_file );", - " yy_load_buffer_state();", - " }", - "", - "", - "%-", - "#ifdef YY_USE_PROTOS", - "void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )", - "#else", - "void yy_switch_to_buffer( new_buffer )", - "YY_BUFFER_STATE new_buffer;", - "#endif", - "%+", - "void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )", - "%*", - " {", - " if ( yy_current_buffer == new_buffer )", - " return;", - "", - " if ( yy_current_buffer )", - " {", - " /* Flush out information for old buffer. */", - " *yy_c_buf_p = yy_hold_char;", - " yy_current_buffer->yy_buf_pos = yy_c_buf_p;", - " yy_current_buffer->yy_n_chars = yy_n_chars;", - " }", - "", - " yy_current_buffer = new_buffer;", - " yy_load_buffer_state();", - "", - " /* We don't actually know whether we did this switch during", - " * EOF (yywrap()) processing, but the only time this flag", - " * is looked at is after yywrap() is called, so it's safe", - " * to go ahead and always set it.", - " */", - " yy_did_buffer_switch_on_eof = 1;", - " }", - "", - "", - "%-", - "#ifdef YY_USE_PROTOS", - "void yy_load_buffer_state( void )", - "#else", - "void yy_load_buffer_state()", - "#endif", - "%+", - "void yyFlexLexer::yy_load_buffer_state()", - "%*", - " {", - " yy_n_chars = yy_current_buffer->yy_n_chars;", - " yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;", - " yyin = yy_current_buffer->yy_input_file;", - " yy_hold_char = *yy_c_buf_p;", - " }", - "", - "", - "%-", - "#ifdef YY_USE_PROTOS", - "YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )", - "#else", - "YY_BUFFER_STATE yy_create_buffer( file, size )", - "FILE *file;", - "int size;", - "#endif", - "%+", - "YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( istream* file, int size )", - "%*", - " {", - " YY_BUFFER_STATE b;", - "", - " b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );", - " if ( ! b )", - " YY_FATAL_ERROR( \"out of dynamic memory in yy_create_buffer()\" );", - "", - " b->yy_buf_size = size;", - "", - " /* yy_ch_buf has to be 2 characters longer than the size given because", - " * we need to put in 2 end-of-buffer characters.", - " */", - " b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );", - " if ( ! b->yy_ch_buf )", - " YY_FATAL_ERROR( \"out of dynamic memory in yy_create_buffer()\" );", - "", - " b->yy_is_our_buffer = 1;", - "", - " yy_init_buffer( b, file );", - "", - " return b;", - " }", - "", - "", - "%-", - "#ifdef YY_USE_PROTOS", - "void yy_delete_buffer( YY_BUFFER_STATE b )", - "#else", - "void yy_delete_buffer( b )", - "YY_BUFFER_STATE b;", - "#endif", - "%+", - "void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b )", - "%*", - " {", - " if ( ! b )", - " return;", - "", - " if ( b == yy_current_buffer )", - " yy_current_buffer = (YY_BUFFER_STATE) 0;", - "", - " if ( b->yy_is_our_buffer )", - " yy_flex_free( (void *) b->yy_ch_buf );", - "", - " yy_flex_free( (void *) b );", - " }", - "", - "", - "%-", - "#ifndef YY_ALWAYS_INTERACTIVE", - "#ifndef YY_NEVER_INTERACTIVE", - "extern int isatty YY_PROTO(( int ));", - "#endif", - "#endif", - "", - "#ifdef YY_USE_PROTOS", - "void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )", - "#else", - "void yy_init_buffer( b, file )", - "YY_BUFFER_STATE b;", - "FILE *file;", - "#endif", - "", - "%+", - "extern \"C\" int isatty YY_PROTO(( int ));", - "void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, istream* file )", - "%*", - "", - " {", - " yy_flush_buffer( b );", - "", - " b->yy_input_file = file;", - " b->yy_fill_buffer = 1;", - "", - "%-", - "#if YY_ALWAYS_INTERACTIVE", - " b->yy_is_interactive = 1;", - "#else", - "#if YY_NEVER_INTERACTIVE", - " b->yy_is_interactive = 0;", - "#else", - " b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;", - "#endif", - "#endif", - "%+", - " b->yy_is_interactive = 0;", - "%*", - " }", - "", - "", - "%-", - "#ifdef YY_USE_PROTOS", - "void yy_flush_buffer( YY_BUFFER_STATE b )", - "#else", - "void yy_flush_buffer( b )", - "YY_BUFFER_STATE b;", - "#endif", - "", - "%+", - "void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b )", - "%*", - " {", - " if ( ! b )", - " return;", - "", - " b->yy_n_chars = 0;", - "", - " /* We always need two end-of-buffer characters. The first causes", - " * a transition to the end-of-buffer state. The second causes", - " * a jam in that state.", - " */", - " b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;", - " b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;", - "", - " b->yy_buf_pos = &b->yy_ch_buf[0];", - "", - " b->yy_at_bol = 1;", - " b->yy_buffer_status = YY_BUFFER_NEW;", - "", - " if ( b == yy_current_buffer )", - " yy_load_buffer_state();", - " }", - "%*", - "", - "", - "#ifndef YY_NO_SCAN_BUFFER", - "%-", - "#ifdef YY_USE_PROTOS", - "YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )", - "#else", - "YY_BUFFER_STATE yy_scan_buffer( base, size )", - "char *base;", - "yy_size_t size;", - "#endif", - " {", - " YY_BUFFER_STATE b;", - "", - " if ( size < 2 ||", - " base[size-2] != YY_END_OF_BUFFER_CHAR ||", - " base[size-1] != YY_END_OF_BUFFER_CHAR )", - " /* They forgot to leave room for the EOB's. */", - " return 0;", - "", - " b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );", - " if ( ! b )", - " YY_FATAL_ERROR( \"out of dynamic memory in yy_scan_buffer()\" );", - "", - " b->yy_buf_size = size - 2; /* \"- 2\" to take care of EOB's */", - " b->yy_buf_pos = b->yy_ch_buf = base;", - " b->yy_is_our_buffer = 0;", - " b->yy_input_file = 0;", - " b->yy_n_chars = b->yy_buf_size;", - " b->yy_is_interactive = 0;", - " b->yy_at_bol = 1;", - " b->yy_fill_buffer = 0;", - " b->yy_buffer_status = YY_BUFFER_NEW;", - "", - " yy_switch_to_buffer( b );", - "", - " return b;", - " }", - "%*", - "#endif", - "", - "", - "#ifndef YY_NO_SCAN_STRING", - "%-", - "#ifdef YY_USE_PROTOS", - "YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )", - "#else", - "YY_BUFFER_STATE yy_scan_string( yy_str )", - "yyconst char *yy_str;", - "#endif", - " {", - " int len;", - " for ( len = 0; yy_str[len]; ++len )", - " ;", - "", - " return yy_scan_bytes( yy_str, len );", - " }", - "%*", - "#endif", - "", - "", - "#ifndef YY_NO_SCAN_BYTES", - "%-", - "#ifdef YY_USE_PROTOS", - "YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )", - "#else", - "YY_BUFFER_STATE yy_scan_bytes( bytes, len )", - "yyconst char *bytes;", - "int len;", - "#endif", - " {", - " YY_BUFFER_STATE b;", - " char *buf;", - " yy_size_t n;", - " int i;", - "", - " /* Get memory for full buffer, including space for trailing EOB's. */", - " n = len + 2;", - " buf = (char *) yy_flex_alloc( n );", - " if ( ! buf )", - " YY_FATAL_ERROR( \"out of dynamic memory in yy_scan_bytes()\" );", - "", - " for ( i = 0; i < len; ++i )", - " buf[i] = bytes[i];", - "", - " buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;", - "", - " b = yy_scan_buffer( buf, n );", - " if ( ! b )", - " YY_FATAL_ERROR( \"bad buffer in yy_scan_bytes()\" );", - "", - " /* It's okay to grow etc. this buffer, and we should throw it", - " * away when we're done.", - " */", - " b->yy_is_our_buffer = 1;", - "", - " return b;", - " }", - "%*", - "#endif", - "", - "", - "#ifndef YY_NO_PUSH_STATE", - "%-", - "#ifdef YY_USE_PROTOS", - "static void yy_push_state( int new_state )", - "#else", - "static void yy_push_state( new_state )", - "int new_state;", - "#endif", - "%+", - "void yyFlexLexer::yy_push_state( int new_state )", - "%*", - " {", - " if ( yy_start_stack_ptr >= yy_start_stack_depth )", - " {", - " yy_size_t new_size;", - "", - " yy_start_stack_depth += YY_START_STACK_INCR;", - " new_size = yy_start_stack_depth * sizeof( int );", - "", - " if ( ! yy_start_stack )", - " yy_start_stack = (int *) yy_flex_alloc( new_size );", - "", - " else", - " yy_start_stack = (int *) yy_flex_realloc(", - " (void *) yy_start_stack, new_size );", - "", - " if ( ! yy_start_stack )", - " YY_FATAL_ERROR(", - " \"out of memory expanding start-condition stack\" );", - " }", - "", - " yy_start_stack[yy_start_stack_ptr++] = YY_START;", - "", - " BEGIN(new_state);", - " }", - "#endif", - "", - "", - "#ifndef YY_NO_POP_STATE", - "%-", - "static void yy_pop_state()", - "%+", - "void yyFlexLexer::yy_pop_state()", - "%*", - " {", - " if ( --yy_start_stack_ptr < 0 )", - " YY_FATAL_ERROR( \"start-condition stack underflow\" );", - "", - " BEGIN(yy_start_stack[yy_start_stack_ptr]);", - " }", - "#endif", - "", - "", - "#ifndef YY_NO_TOP_STATE", - "%-", - "static int yy_top_state()", - "%+", - "int yyFlexLexer::yy_top_state()", - "%*", - " {", - " return yy_start_stack[yy_start_stack_ptr - 1];", - " }", - "#endif", - "", - "#ifndef YY_EXIT_FAILURE", - "#define YY_EXIT_FAILURE 2", - "#endif", - "", - "%-", - "#ifdef YY_USE_PROTOS", - "static void yy_fatal_error( yyconst char msg[] )", - "#else", - "static void yy_fatal_error( msg )", - "char msg[];", - "#endif", - " {", - " (void) fprintf( stderr, \"%s\\n\", msg );", - " exit( YY_EXIT_FAILURE );", - " }", - "", - "%+", - "", - "void yyFlexLexer::LexerError( yyconst char msg[] )", - " {", - " cerr << msg << '\\n';", - " exit( YY_EXIT_FAILURE );", - " }", - "%*", - "", - "", - "/* Redefine yyless() so it works in section 3 code. */", - "", - "#undef yyless", - "#define yyless(n) \\", - " do \\", - " { \\", - " /* Undo effects of setting up yytext. */ \\", - " yytext[yyleng] = yy_hold_char; \\", - " yy_c_buf_p = yytext + n; \\", - " yy_hold_char = *yy_c_buf_p; \\", - " *yy_c_buf_p = '\\0'; \\", - " yyleng = n; \\", - " } \\", - " while ( 0 )", - "", - "", - "/* Internal utility routines. */", - "", - "#ifndef yytext_ptr", - "#ifdef YY_USE_PROTOS", - "static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )", - "#else", - "static void yy_flex_strncpy( s1, s2, n )", - "char *s1;", - "yyconst char *s2;", - "int n;", - "#endif", - " {", - " 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", - "", - "", - "#ifdef YY_USE_PROTOS", - "static void *yy_flex_alloc( yy_size_t size )", - "#else", - "static void *yy_flex_alloc( size )", - "yy_size_t size;", - "#endif", - " {", - " return (void *) malloc( size );", - " }", - "", - "#ifdef YY_USE_PROTOS", - "static void *yy_flex_realloc( void *ptr, yy_size_t size )", - "#else", - "static void *yy_flex_realloc( ptr, size )", - "void *ptr;", - "yy_size_t size;", - "#endif", - " {", - " /* The cast to (char *) in the following accommodates both", - " * implementations that use char* generic pointers, and those", - " * that use void* generic pointers. It works with the latter", - " * because both ANSI C and C++ allow castless assignment from", - " * any pointer type to void*, and deal with argument conversions", - " * as though doing an assignment.", - " */", - " return (void *) realloc( (char *) ptr, size );", - " }", - "", - "#ifdef YY_USE_PROTOS", - "static void yy_flex_free( void *ptr )", - "#else", - "static void yy_flex_free( ptr )", - "void *ptr;", - "#endif", - " {", - " free( ptr );", - " }", - "", - "#if YY_MAIN", - "int main()", - " {", - " yylex();", - " return 0;", - " }", - "#endif", - 0 -}; diff --git a/commands/fold/Makefile b/commands/fold/Makefile new file mode 100644 index 000000000..2a8cd607f --- /dev/null +++ b/commands/fold/Makefile @@ -0,0 +1,4 @@ +PROG= fold +MAN= + +.include diff --git a/commands/simple/fold.c b/commands/fold/fold.c similarity index 100% rename from commands/simple/fold.c rename to commands/fold/fold.c diff --git a/commands/format/Makefile b/commands/format/Makefile new file mode 100644 index 000000000..7c511487a --- /dev/null +++ b/commands/format/Makefile @@ -0,0 +1,5 @@ +PROG= format +BIMODE= 4755 +MAN= + +.include diff --git a/commands/ibm/format.c b/commands/format/format.c similarity index 100% rename from commands/ibm/format.c rename to commands/format/format.c diff --git a/commands/fortune/Makefile b/commands/fortune/Makefile new file mode 100644 index 000000000..d05678ca4 --- /dev/null +++ b/commands/fortune/Makefile @@ -0,0 +1,4 @@ +PROG= fortune +MAN= + +.include diff --git a/commands/simple/fortune.c b/commands/fortune/fortune.c similarity index 100% rename from commands/simple/fortune.c rename to commands/fortune/fortune.c diff --git a/commands/fsck/Makefile b/commands/fsck/Makefile new file mode 100644 index 000000000..b700f96c4 --- /dev/null +++ b/commands/fsck/Makefile @@ -0,0 +1,6 @@ +PROG= fsck +CPPFLAGS+= -I${MINIXSRCDIR}/servers +BINDIR= /bin +MAN= + +.include diff --git a/commands/simple/fsck.c b/commands/fsck/fsck.c similarity index 99% rename from commands/simple/fsck.c rename to commands/fsck/fsck.c index 089161119..fbe469a53 100644 --- a/commands/simple/fsck.c +++ b/commands/fsck/fsck.c @@ -48,9 +48,9 @@ #include #include #include -#include "../../servers/mfs/const.h" -#include "../../servers/mfs/inode.h" -#include "../../servers/mfs/type.h" +#include "mfs/const.h" +#include "mfs/inode.h" +#include "mfs/type.h" #include #include #include @@ -88,7 +88,7 @@ unsigned int fs_version = 2, block_size = 0; #define ZONE_CT 360 /* default zones (when making file system) */ #define INODE_CT 95 /* default inodes (when making file system) */ -#include "../../servers/mfs/super.h" +#include "mfs/super.h" static struct super_block sb; #define STICKY_BIT 01000 /* not defined anywhere else */ diff --git a/commands/fsck1/Makefile b/commands/fsck1/Makefile new file mode 100644 index 000000000..503541e10 --- /dev/null +++ b/commands/fsck1/Makefile @@ -0,0 +1,5 @@ +PROG= fsck1 +CPPFLAGS+= -I${MINIXSRCDIR}/servers +MAN= + +.include diff --git a/commands/simple/fsck1.c b/commands/fsck1/fsck1.c similarity index 99% rename from commands/simple/fsck1.c rename to commands/fsck1/fsck1.c index 87c935ca5..6fce5421c 100644 --- a/commands/simple/fsck1.c +++ b/commands/fsck1/fsck1.c @@ -47,9 +47,9 @@ #include #include #include -#include "../../servers/mfs/const.h" -#include "../../servers/mfs/inode.h" -#include "../../servers/mfs/type.h" +#include "mfs/const.h" +#include "mfs/inode.h" +#include "mfs/type.h" #include #include #include @@ -69,7 +69,7 @@ #define ZONE_CT 360 /* default zones (when making file system) */ #define INODE_CT 95 /* default inodes (when making file system) */ -#include "../../servers/mfs/super.h" +#include "mfs/super.h" struct super_block sb; #define STICKY_BIT 01000 /* not defined anywhere else */ diff --git a/commands/ftp101/Makefile b/commands/ftp101/Makefile index f854352e9..5b07ec2a1 100644 --- a/commands/ftp101/Makefile +++ b/commands/ftp101/Makefile @@ -4,39 +4,8 @@ # 03/08/00 Michael Temari, # 02/07/05 v. 1.01 Michael Temari, -CFLAGS= -O -D_MINIX -D_POSIX_SOURCE -m -LDFLAGS=-i -BINDIR=/usr/bin PROG= ftp -MANPAGE= /usr/local/man/man1 +SRCS= ftp.c local.c file.c xfer.c other.c net.c crc.c +CPPFLAGS+= -DCRC_ONLY -m -OBJS= ftp.o local.o file.o xfer.o other.o net.o crc.o - -all: $(PROG) - -$(PROG): $(OBJS) - $(CC) $(LDFLAGS) -o $@ $(OBJS) - install -S 8kw $@ - -clean: - rm -f $(PROG) $(OBJS) - -install: $(BINDIR)/$(PROG) - -$(BINDIR)/$(PROG): $(PROG) - install -cs -o bin $? $@ - -installman: $(MANPAGE) - - cp ftp.1 /usr/local/man/man1 - makewhatis /usr/local/man - -crc.o: crc.c - $(CC) -c $(CFLAGS) -DCRC_ONLY $? - -ftp.o: ftp.c ftp.h local.h file.h other.h net.h -local.o: local.c ftp.h local.h -file.o: file.c ftp.h file.h net.h -other.o: other.c ftp.h other.h -net.o: net.c ftp.h xfer.h net.h -xfer.o: xfer.c ftp.h xfer.h +.include diff --git a/commands/ftpd200/Makefile b/commands/ftpd200/Makefile index 249b5a166..d0090c66a 100644 --- a/commands/ftpd200/Makefile +++ b/commands/ftpd200/Makefile @@ -3,41 +3,11 @@ # 01/25/96 Initial Release Michael Temari, # 2005-02-25 version 2.00 -CFLAGS= -O -D_MINIX -D_POSIX_SOURCE -m -LDFLAGS=-i -BINDIR= /usr/bin PROG= in.ftpd -MANDIR= /usr/man/man8 -MANPAGE=ftpd.8 -CC = exec cc +SRCS= ftpd.c access.c file.c net.c +CPPFLAGS+= -m +MAN= ftpd.8 +SCRIPTS= ftpdsh +FILES= setup.anonftp -OBJS= ftpd.o access.o file.o net.o - -all: $(PROG) - -$(PROG): $(OBJS) - $(CC) $(LDFLAGS) -o $@ $(OBJS) - install -S 8kw $@ - -clean: - rm -f $(PROG) $(OBJS) - -install: $(BINDIR)/$(PROG) $(BINDIR)/setup.anonftp $(BINDIR)/ftpdsh - -$(BINDIR)/$(PROG): $(PROG) - install -cs -o bin $? $@ - -$(BINDIR)/setup.anonftp: setup.anonftp - install -c -o bin $? $@ - -$(BINDIR)/ftpdsh: ftpdsh - install -m 755 -c -o bin $? $@ - -ftpd.o: ftpd.c ftpd.h access.h file.h net.h -access.o: access.c ftpd.h access.h -file.o: file.c ftpd.h access.h file.h net.h -net.o: net.c ftpd.h net.h - -installman: $(MANDIR)/$(MANPAGE) - cp $(MANPAGE) $(MANDIR) - echo "You may need to run makewhatis to update man page index" +.include diff --git a/commands/ftpd200/build b/commands/ftpd200/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/ftpd200/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/gas2ack/Makefile b/commands/gas2ack/Makefile new file mode 100644 index 000000000..861b1c6db --- /dev/null +++ b/commands/gas2ack/Makefile @@ -0,0 +1,8 @@ +# Makefile for gas2ack. + +PROG= gas2ack +SRCS= asm86.c gas2ack.c globals.c parse_gnu.c \ + tokenize.c emit_ack.c +MAN= + +.include diff --git a/commands/i386/gas2ack/asm86.c b/commands/gas2ack/asm86.c similarity index 100% rename from commands/i386/gas2ack/asm86.c rename to commands/gas2ack/asm86.c diff --git a/commands/i386/gas2ack/asm86.h b/commands/gas2ack/asm86.h similarity index 100% rename from commands/i386/gas2ack/asm86.h rename to commands/gas2ack/asm86.h diff --git a/commands/i386/gas2ack/asmconv.h b/commands/gas2ack/asmconv.h similarity index 100% rename from commands/i386/gas2ack/asmconv.h rename to commands/gas2ack/asmconv.h diff --git a/commands/i386/gas2ack/emit_ack.c b/commands/gas2ack/emit_ack.c similarity index 100% rename from commands/i386/gas2ack/emit_ack.c rename to commands/gas2ack/emit_ack.c diff --git a/commands/i386/gas2ack/gas2ack.c b/commands/gas2ack/gas2ack.c similarity index 100% rename from commands/i386/gas2ack/gas2ack.c rename to commands/gas2ack/gas2ack.c diff --git a/commands/i386/gas2ack/globals.c b/commands/gas2ack/globals.c similarity index 100% rename from commands/i386/gas2ack/globals.c rename to commands/gas2ack/globals.c diff --git a/commands/i386/gas2ack/globals.h b/commands/gas2ack/globals.h similarity index 100% rename from commands/i386/gas2ack/globals.h rename to commands/gas2ack/globals.h diff --git a/commands/i386/gas2ack/languages.h b/commands/gas2ack/languages.h similarity index 100% rename from commands/i386/gas2ack/languages.h rename to commands/gas2ack/languages.h diff --git a/commands/i386/gas2ack/parse_gnu.c b/commands/gas2ack/parse_gnu.c similarity index 100% rename from commands/i386/gas2ack/parse_gnu.c rename to commands/gas2ack/parse_gnu.c diff --git a/commands/i386/gas2ack/token.h b/commands/gas2ack/token.h similarity index 100% rename from commands/i386/gas2ack/token.h rename to commands/gas2ack/token.h diff --git a/commands/i386/gas2ack/tokenize.c b/commands/gas2ack/tokenize.c similarity index 100% rename from commands/i386/gas2ack/tokenize.c rename to commands/gas2ack/tokenize.c diff --git a/commands/getty/Makefile b/commands/getty/Makefile new file mode 100644 index 000000000..9e19d85e4 --- /dev/null +++ b/commands/getty/Makefile @@ -0,0 +1,5 @@ +PROG= getty +BINDIR= /bin +MAN= + +.include diff --git a/commands/simple/getty.c b/commands/getty/getty.c similarity index 100% rename from commands/simple/getty.c rename to commands/getty/getty.c diff --git a/commands/gomoku/Makefile b/commands/gomoku/Makefile new file mode 100644 index 000000000..e978157e9 --- /dev/null +++ b/commands/gomoku/Makefile @@ -0,0 +1,7 @@ +PROG= gomoku +MAN= + +DPADD+= ${LIBCURSES} +LDADD+= -lcurses + +.include diff --git a/commands/simple/gomoku.c b/commands/gomoku/gomoku.c similarity index 100% rename from commands/simple/gomoku.c rename to commands/gomoku/gomoku.c diff --git a/commands/grep/Makefile b/commands/grep/Makefile new file mode 100644 index 000000000..572079233 --- /dev/null +++ b/commands/grep/Makefile @@ -0,0 +1,6 @@ +PROG= grep +MAN= + +LINKS+= ${BINDIR}/grep ${BINDIR}/egrep + +.include diff --git a/commands/simple/grep.c b/commands/grep/grep.c similarity index 100% rename from commands/simple/grep.c rename to commands/grep/grep.c diff --git a/commands/head/Makefile b/commands/head/Makefile new file mode 100644 index 000000000..f306dbc46 --- /dev/null +++ b/commands/head/Makefile @@ -0,0 +1,4 @@ +PROG= head +MAN= + +.include diff --git a/commands/simple/head.c b/commands/head/head.c similarity index 100% rename from commands/simple/head.c rename to commands/head/head.c diff --git a/commands/host/Makefile b/commands/host/Makefile new file mode 100644 index 000000000..a9ba3c3ca --- /dev/null +++ b/commands/host/Makefile @@ -0,0 +1,4 @@ +PROG= host +MAN= + +.include diff --git a/commands/simple/host.c b/commands/host/host.c similarity index 100% rename from commands/simple/host.c rename to commands/host/host.c diff --git a/commands/hostaddr/Makefile b/commands/hostaddr/Makefile new file mode 100644 index 000000000..fd2f749d9 --- /dev/null +++ b/commands/hostaddr/Makefile @@ -0,0 +1,5 @@ +PROG= hostaddr +BINMODE= 4755 +MAN= + +.include diff --git a/commands/simple/hostaddr.c b/commands/hostaddr/hostaddr.c similarity index 100% rename from commands/simple/hostaddr.c rename to commands/hostaddr/hostaddr.c diff --git a/commands/i386/Makefile b/commands/i386/Makefile deleted file mode 100644 index 39020233f..000000000 --- a/commands/i386/Makefile +++ /dev/null @@ -1,31 +0,0 @@ -# Makefile for commands/i386. - -CFLAGS = -D_MINIX -D_POSIX_SOURCE -CCLD = $(CC) -i $(CFLAGS) -MAKE = exec make -$(MAKEFLAGS) -CC = exec cc - -all:: acd - -acd: acd.c - $(CCLD) -o $@ -DARCH=\"`arch`\" -DDESCR=\"/usr/lib/descr\" $? - install -S 50kw $@ - -install:: /usr/bin/acd /usr/bin/cc /usr/bin/m2 /usr/bin/pc \ - /usr/lib/descr - -/usr/bin/acd: acd - install -cs -o bin $? $@ - -/usr/bin/cc /usr/bin/m2 /usr/bin/pc: /usr/bin/acd - install -l h $? $@ - -/usr/lib/descr: acd.descr - install $? $@ - -clean:: - rm -rf a.out core acd - -all install clean:: - cd asmconv && $(MAKE) $@ - cd gas2ack && $(MAKE) $@ diff --git a/commands/i386/asmconv/Makefile b/commands/i386/asmconv/Makefile deleted file mode 100644 index 3c9995191..000000000 --- a/commands/i386/asmconv/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -# Makefile for asmconv. - -CFLAGS= $(OPT) -LDFLAGS= -i -CC = exec cc - -all: asmconv - -OBJ= asm86.o asmconv.o parse_ack.o parse_gnu.o parse_bas.o \ - tokenize.o emit_ack.o emit_gnu.o - -asmconv: $(OBJ) - $(CC) $(LDFLAGS) -o $@ $(OBJ) - install -S 8kw $@ - -install: /usr/bin/asmconv - -/usr/bin/asmconv: asmconv - install -cs -o bin asmconv $@ - -clean: - rm -f $(OBJ) asmconv core - -# Dependencies. -asm86.o: asm86.h asmconv.h token.h -asmconv.o: asmconv.h languages.h asm86.h -parse_ack.o: asmconv.h languages.h token.h asm86.h -parse_gnu.o: asmconv.h languages.h token.h asm86.h -parse_bas.o: asmconv.h languages.h token.h asm86.h -tokenize.o: asmconv.h token.h -emit_ack.o: asmconv.h languages.h token.h asm86.h -emit_gnu.o: asmconv.h languages.h token.h asm86.h diff --git a/commands/i386/asmconv/build b/commands/i386/asmconv/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/i386/asmconv/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/i386/build b/commands/i386/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/i386/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/i386/gas2ack/Makefile b/commands/i386/gas2ack/Makefile deleted file mode 100644 index 3c25c6a9d..000000000 --- a/commands/i386/gas2ack/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -# Makefile for gas2ack. - -CFLAGS= $(OPT) -LDFLAGS= -i -CC = exec cc - -all: gas2ack - -OBJ= asm86.o gas2ack.o globals.o parse_gnu.o \ - tokenize.o emit_ack.o - -gas2ack: $(OBJ) - $(CC) $(LDFLAGS) -o $@ $(OBJ) - -install: /usr/bin/gas2ack - -/usr/bin/gas2ack: gas2ack - install -cs -o bin gas2ack $@ - -clean: - rm -f $(OBJ) gas2ack core - -# Dependencies. -asm86.o: asm86.h asmconv.h token.h -gas2ack.o: asmconv.h languages.h asm86.h -globals.o: asm86.h -parse_gnu.o: asmconv.h languages.h token.h asm86.h -tokenize.o: asmconv.h token.h -emit_ack.o: asmconv.h languages.h token.h asm86.h diff --git a/commands/ibm/Makefile b/commands/ibm/Makefile deleted file mode 100644 index c873d7596..000000000 --- a/commands/ibm/Makefile +++ /dev/null @@ -1,168 +0,0 @@ -# Makefile for commands/ibm. - -# See commands/simple/Makefile for a description. - -CFLAGS = -D_MINIX -D_POSIX_SOURCE -CCLD = $(CC) -i $(CFLAGS) -MAKE = exec make -$(MAKEFLAGS) -CC = exec cc - -ALL = \ - atnormalize \ - dosread \ - fdisk \ - format \ - loadfont \ - loadkeys \ - mixer \ - autopart \ - part \ - partition \ - playwave \ - postmort \ - recwave \ - repartition \ - screendump - -all: $(ALL) - -dosread: dosread.c - $(CCLD) -o $@ $? - install -S 16kw $@ - -atnormalize: atnormalize.c - $(CCLD) -o $@ $? - install -S 16kw $@ - -fdisk: fdisk.c - $(CCLD) -o $@ $? - install -S 4kw $@ - -format: format.c - $(CCLD) -o $@ $? - install -S 4kw $@ - -loadfont: loadfont.c - $(CCLD) -o $@ $? - install -S 4kw $@ - -loadkeys: loadkeys.c - $(CCLD) -o $@ $? - install -S 4kw $@ - -mixer: mixer.c - $(CCLD) -o $@ $? -lcurses - install -S 16kw $@ - -autopart: autopart.c - $(CCLD) -o $@ $? - install -S 11kw $@ - -part: part.c - $(CCLD) -o $@ $? - install -S 11kw $@ - -partition: partition.c - $(CCLD) -o $@ $? - install -S 4kw $@ - -playwave: playwave.c - $(CCLD) -o $@ $? - install -S 16kw $@ - -postmort: postmort.c - $(CCLD) -o $@ $? - install -S 4kw $@ - -recwave: recwave.c - $(CCLD) -o $@ $? - install -S 16kw $@ - -repartition: repartition.c - $(CCLD) -o $@ $? - install -S 4kw $@ - -screendump: screendump.c - $(CCLD) -o $@ $? - install -S 4kw $@ - -sdump: sdump.c - $(CCLD) -o $@ $? - install -S 4kw $@ - -install: \ - /usr/bin/atnormalize \ - /usr/bin/dosread \ - /usr/bin/dosdir \ - /usr/bin/doswrite \ - /usr/bin/fdisk \ - /usr/bin/format \ - /usr/bin/loadfont \ - /usr/bin/loadkeys \ - /usr/bin/mixer \ - /usr/bin/autopart \ - /usr/bin/part \ - /usr/bin/partition \ - /usr/bin/playwave \ - /usr/bin/postmort \ - /usr/bin/recwave \ - /usr/bin/repartition \ - /usr/bin/screendump \ - /bin/loadkeys \ - -/usr/bin/atnormalize: atnormalize - install -cs -o bin $? $@ - -/usr/bin/dosread: dosread - install -cs -o bin $? $@ - -/usr/bin/dosdir /usr/bin/doswrite: /usr/bin/dosread - install -l h $? $@ - -/usr/bin/fdisk: fdisk - install -cs -o bin $? $@ - -/usr/bin/format: format - install -cs -o root -m 4755 $? $@ - -/usr/bin/loadfont: loadfont - install -cs -o bin $? $@ - -/usr/bin/loadkeys: loadkeys - install -cs -o bin $? $@ - -/usr/bin/mixer: mixer - install -cs -o bin $? $@ - -/usr/bin/autopart: autopart - install -l h -cs $? $@ - -/usr/bin/part: part - install -cs -o bin $? $@ - -/usr/bin/partition: partition - install -cs -o bin $? $@ - -/usr/bin/playwave: playwave - install -cs -o bin $? $@ - -/usr/bin/postmort: postmort - install -cs -o bin $? $@ - -/usr/bin/recwave: recwave - install -cs -o bin $? $@ - -/usr/bin/repartition: repartition - install -cs -o bin $? $@ - -/usr/bin/screendump: screendump - install -cs -o bin $? $@ - -/usr/bin/sdump: sdump - install -cs -o bin $? $@ - -/bin/loadkeys: /usr/bin/loadkeys - install -l h -cs $? $@ - -clean: - rm -rf $(ALL) a.out core diff --git a/commands/ibm/build b/commands/ibm/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/ibm/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/id/Makefile b/commands/id/Makefile new file mode 100644 index 000000000..c0e6aa934 --- /dev/null +++ b/commands/id/Makefile @@ -0,0 +1,4 @@ +PROG= id +MAN= + +.include diff --git a/commands/simple/id.c b/commands/id/id.c similarity index 100% rename from commands/simple/id.c rename to commands/id/id.c diff --git a/commands/ifconfig/Makefile b/commands/ifconfig/Makefile new file mode 100644 index 000000000..821037694 --- /dev/null +++ b/commands/ifconfig/Makefile @@ -0,0 +1,5 @@ +PROG= ifconfig +BINMODE= 4755 +MAN= + +.include diff --git a/commands/simple/ifconfig.c b/commands/ifconfig/ifconfig.c similarity index 100% rename from commands/simple/ifconfig.c rename to commands/ifconfig/ifconfig.c diff --git a/commands/ifdef/Makefile b/commands/ifdef/Makefile new file mode 100644 index 000000000..e7b5e3d38 --- /dev/null +++ b/commands/ifdef/Makefile @@ -0,0 +1,4 @@ +PROG= ifdef +MAN= + +.include diff --git a/commands/simple/ifdef.c b/commands/ifdef/ifdef.c similarity index 100% rename from commands/simple/ifdef.c rename to commands/ifdef/ifdef.c diff --git a/commands/indent/Makefile b/commands/indent/Makefile index 35581d74d..de64f5b37 100644 --- a/commands/indent/Makefile +++ b/commands/indent/Makefile @@ -1,22 +1,8 @@ # Makefile for indent -CFLAGS= -c -O -D_MINIX -D_POSIX_SOURCE -wo -m -CC = exec cc +PROG= indent +SRCS= args.c comment.c lexi.c indent.c parse.c io.c +CPPFLAGS+= -wo -m +MAN= -all: indent - -OBJ = args.o comment.o lexi.o indent.o parse.o io.o - -indent: ${OBJ} - $(CC) -o indent -i ${OBJ} - install -S 32kw $@ - -install: /usr/bin/indent - -/usr/bin/indent: indent - install -cs -o bin indent $@ - -$(OBJ): globs.h codes.h - -clean: - rm -f *.bak *.o core indent +.include diff --git a/commands/indent/build b/commands/indent/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/indent/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/install/Makefile b/commands/install/Makefile new file mode 100644 index 000000000..80446269a --- /dev/null +++ b/commands/install/Makefile @@ -0,0 +1,9 @@ +PROG= xinstall +SRCS= install.c +BINDIR= /bin +BINMODE= 4755 +MAN= + +PROGNAME=install + +.include diff --git a/commands/simple/install.c b/commands/install/install.c similarity index 100% rename from commands/simple/install.c rename to commands/install/install.c diff --git a/commands/intr/Makefile b/commands/intr/Makefile new file mode 100644 index 000000000..b990facb7 --- /dev/null +++ b/commands/intr/Makefile @@ -0,0 +1,5 @@ +PROG= intr +BINDIR= /bin +MAN= + +.include diff --git a/commands/simple/intr.c b/commands/intr/intr.c similarity index 100% rename from commands/simple/intr.c rename to commands/intr/intr.c diff --git a/commands/ipcrm/Makefile b/commands/ipcrm/Makefile new file mode 100644 index 000000000..8ee2ee29e --- /dev/null +++ b/commands/ipcrm/Makefile @@ -0,0 +1,4 @@ +PROG= ipcrm +MAN= + +.include diff --git a/commands/simple/ipcrm.c b/commands/ipcrm/ipcrm.c similarity index 100% rename from commands/simple/ipcrm.c rename to commands/ipcrm/ipcrm.c diff --git a/commands/ipcs/Makefile b/commands/ipcs/Makefile new file mode 100644 index 000000000..10d2772a0 --- /dev/null +++ b/commands/ipcs/Makefile @@ -0,0 +1,4 @@ +PROG= ipcs +MAN= + +.include diff --git a/commands/simple/ipcs.c b/commands/ipcs/ipcs.c similarity index 100% rename from commands/simple/ipcs.c rename to commands/ipcs/ipcs.c diff --git a/commands/irdpd/Makefile b/commands/irdpd/Makefile new file mode 100644 index 000000000..c37192359 --- /dev/null +++ b/commands/irdpd/Makefile @@ -0,0 +1,4 @@ +PROG= irdpd +MAN= + +.include diff --git a/commands/simple/irdpd.c b/commands/irdpd/irdpd.c similarity index 100% rename from commands/simple/irdpd.c rename to commands/irdpd/irdpd.c diff --git a/commands/isoread/Makefile b/commands/isoread/Makefile new file mode 100644 index 000000000..d77ca8cad --- /dev/null +++ b/commands/isoread/Makefile @@ -0,0 +1,7 @@ +PROG= isoread +MAN= + +LINKS+= ${BINDIR}/isoread ${BINDIR}/isodir +LINKS+= ${BINDIR}/isoread ${BINDIR}/isoinfo + +.include diff --git a/commands/simple/isoread.c b/commands/isoread/isoread.c similarity index 100% rename from commands/simple/isoread.c rename to commands/isoread/isoread.c diff --git a/commands/join/Makefile b/commands/join/Makefile new file mode 100644 index 000000000..b08ac31c9 --- /dev/null +++ b/commands/join/Makefile @@ -0,0 +1,4 @@ +PROG= join +MAN= + +.include diff --git a/commands/simple/join.c b/commands/join/join.c similarity index 100% rename from commands/simple/join.c rename to commands/join/join.c diff --git a/commands/kill/Makefile b/commands/kill/Makefile new file mode 100644 index 000000000..26a0c6f88 --- /dev/null +++ b/commands/kill/Makefile @@ -0,0 +1,4 @@ +PROG= kill +MAN= + +.include diff --git a/commands/simple/kill.c b/commands/kill/kill.c similarity index 100% rename from commands/simple/kill.c rename to commands/kill/kill.c diff --git a/commands/last/Makefile b/commands/last/Makefile new file mode 100644 index 000000000..ffb7ca37b --- /dev/null +++ b/commands/last/Makefile @@ -0,0 +1,6 @@ +PROG= last +MAN= + +LINKS+= ${BINDIR}/last ${BINDIR}/uptime + +.include diff --git a/commands/simple/last.c b/commands/last/last.c similarity index 100% rename from commands/simple/last.c rename to commands/last/last.c diff --git a/commands/leave/Makefile b/commands/leave/Makefile new file mode 100644 index 000000000..e2d62d1fe --- /dev/null +++ b/commands/leave/Makefile @@ -0,0 +1,4 @@ +PROG= leave +MAN= + +.include diff --git a/commands/simple/leave.c b/commands/leave/leave.c similarity index 100% rename from commands/simple/leave.c rename to commands/leave/leave.c diff --git a/commands/flex-2.5.4/COPYING b/commands/lex/COPYING similarity index 100% rename from commands/flex-2.5.4/COPYING rename to commands/lex/COPYING diff --git a/commands/flex-2.5.4/FlexLexer.h b/commands/lex/FlexLexer.h similarity index 100% rename from commands/flex-2.5.4/FlexLexer.h rename to commands/lex/FlexLexer.h diff --git a/commands/lex/Makefile b/commands/lex/Makefile new file mode 100644 index 000000000..6d0d99630 --- /dev/null +++ b/commands/lex/Makefile @@ -0,0 +1,44 @@ +# from: @(#)Makefile 5.4 (Berkeley) 6/24/90 +# $NetBSD: Makefile,v 1.29 2009/04/14 22:15:22 lukem Exp $ +# +# By default, flex will be configured to generate 8-bit scanners only if the +# -8 flag is given. If you want it to always generate 8-bit scanners, add +# "-DDEFAULT_CSIZE=256" to CPPFLAGS. Note that doing so will double the size +# of all uncompressed scanners. +# +# If on your system you have trouble building flex due to 8-bit character +# problems, remove the -8 from FLEX_FLAGS and the "#define FLEX_8_BIT_CHARS" +# from the beginning of flexdef.h. +# +# To bootstrap lex, cp initscan.c to scan.c and run make. + +#WARNS?= 1 # XXX many -Wshadow -Wcast-qual issues + +PROG= lex +CPPFLAGS+=-I. -I${.CURDIR} +SRCS= ccl.c dfa.c ecs.c gen.c main.c misc.c nfa.c parse.y sym.c tblcmp.c \ + yylex.c scan.c skel.c +YHEADER=1 +CLEANFILES+=scan.c skel.c +INCS =FlexLexer.h +INCSDIR=/usr/local/include + +MAN= flex.1 + +LINKS= ${BINDIR}/lex ${BINDIR}/flex \ + ${BINDIR}/lex ${BINDIR}/flex++ +MLINKS= flex.1 lex.1 + +skel.c: mkskel.sh flex.skl + ${_MKTARGET_CREATE} + ${HOST_SH} ${.ALLSRC} >${.TARGET} + +.ifndef HOSTPROG +scan.c: scan.l + ${_MKTARGET_LEX} + ${LEX} -t -p ${.ALLSRC} >${.TARGET} +.endif + +scan.o yylex.o: parse.h + +.include diff --git a/commands/flex-2.5.4/NEWS b/commands/lex/NEWS similarity index 100% rename from commands/flex-2.5.4/NEWS rename to commands/lex/NEWS diff --git a/commands/flex-2.5.4/ccl.c b/commands/lex/ccl.c similarity index 100% rename from commands/flex-2.5.4/ccl.c rename to commands/lex/ccl.c diff --git a/commands/flex-2.5.4/MISC/NT/config.h b/commands/lex/config.h similarity index 64% rename from commands/flex-2.5.4/MISC/NT/config.h rename to commands/lex/config.h index 17e831a95..8e6540c7f 100644 --- a/commands/flex-2.5.4/MISC/NT/config.h +++ b/commands/lex/config.h @@ -1,6 +1,5 @@ /* config.h. Generated automatically by configure. */ -/* $Header: /home/daffy/u0/vern/flex/RCS/conf.in,v 1.2 95/01/09 -12:11:51 vern Exp $ */ +/* $NetBSD: config.h,v 1.4 1998/02/22 12:08:34 christos Exp $ */ /* Define to empty if the keyword does not work. */ /* #undef const */ @@ -12,21 +11,19 @@ #define STDC_HEADERS 1 /* Define if you have the header file. */ -#define HAVE_MALLOC_H 1 +/* #undef HAVE_MALLOC_H 1 */ /* Define if you have the header file. */ #define HAVE_STRING_H 1 +/* Define if you have the header file. */ +#define HAVE_UNISTD_H 1 + /* Define if you have the header file. */ #define HAVE_SYS_TYPES_H 1 -/* Define if you have and it should be used (not on -Ultrix). */ -#define HAVE_ALLOCA_H 0 +/* Define if you have and it should be used (not on Ultrix). */ +/* #undef HAVE_ALLOCA_H */ /* Define if platform-specific command line handling is necessary. */ /* #undef NEED_ARGV_FIXUP */ - -/* Define if you use FAT file system, leave undefined for NTFS */ -#undef SHORT_FILE_NAMES -/* #define SHORT_FILE_NAMES 1 */ diff --git a/commands/flex-2.5.4/dfa.c b/commands/lex/dfa.c similarity index 100% rename from commands/flex-2.5.4/dfa.c rename to commands/lex/dfa.c diff --git a/commands/flex-2.5.4/ecs.c b/commands/lex/ecs.c similarity index 100% rename from commands/flex-2.5.4/ecs.c rename to commands/lex/ecs.c diff --git a/commands/flex-2.5.4/flex.1 b/commands/lex/flex.1 similarity index 100% rename from commands/flex-2.5.4/flex.1 rename to commands/lex/flex.1 diff --git a/commands/flex-2.5.4/flex.skl b/commands/lex/flex.skl similarity index 100% rename from commands/flex-2.5.4/flex.skl rename to commands/lex/flex.skl diff --git a/commands/flex-2.5.4/flexdef.h b/commands/lex/flexdef.h similarity index 100% rename from commands/flex-2.5.4/flexdef.h rename to commands/lex/flexdef.h diff --git a/commands/flex-2.5.4/gen.c b/commands/lex/gen.c similarity index 100% rename from commands/flex-2.5.4/gen.c rename to commands/lex/gen.c diff --git a/commands/flex-2.5.4/initscan.c b/commands/lex/initscan.c similarity index 100% rename from commands/flex-2.5.4/initscan.c rename to commands/lex/initscan.c diff --git a/commands/flex-2.5.4/libmain.c b/commands/lex/libmain.c similarity index 100% rename from commands/flex-2.5.4/libmain.c rename to commands/lex/libmain.c diff --git a/commands/flex-2.5.4/libyywrap.c b/commands/lex/libyywrap.c similarity index 100% rename from commands/flex-2.5.4/libyywrap.c rename to commands/lex/libyywrap.c diff --git a/commands/flex-2.5.4/main.c b/commands/lex/main.c similarity index 100% rename from commands/flex-2.5.4/main.c rename to commands/lex/main.c diff --git a/commands/flex-2.5.4/misc.c b/commands/lex/misc.c similarity index 100% rename from commands/flex-2.5.4/misc.c rename to commands/lex/misc.c diff --git a/commands/flex-2.5.4/mkskel.sh b/commands/lex/mkskel.sh similarity index 100% rename from commands/flex-2.5.4/mkskel.sh rename to commands/lex/mkskel.sh diff --git a/commands/flex-2.5.4/nfa.c b/commands/lex/nfa.c similarity index 100% rename from commands/flex-2.5.4/nfa.c rename to commands/lex/nfa.c diff --git a/commands/flex-2.5.4/parse.y b/commands/lex/parse.y similarity index 100% rename from commands/flex-2.5.4/parse.y rename to commands/lex/parse.y diff --git a/commands/flex-2.5.4/scan.l b/commands/lex/scan.l similarity index 100% rename from commands/flex-2.5.4/scan.l rename to commands/lex/scan.l diff --git a/commands/flex-2.5.4/sym.c b/commands/lex/sym.c similarity index 100% rename from commands/flex-2.5.4/sym.c rename to commands/lex/sym.c diff --git a/commands/flex-2.5.4/tblcmp.c b/commands/lex/tblcmp.c similarity index 100% rename from commands/flex-2.5.4/tblcmp.c rename to commands/lex/tblcmp.c diff --git a/commands/flex-2.5.4/version.h b/commands/lex/version.h similarity index 100% rename from commands/flex-2.5.4/version.h rename to commands/lex/version.h diff --git a/commands/flex-2.5.4/yylex.c b/commands/lex/yylex.c similarity index 100% rename from commands/flex-2.5.4/yylex.c rename to commands/lex/yylex.c diff --git a/commands/life/Makefile b/commands/life/Makefile new file mode 100644 index 000000000..3e62b057f --- /dev/null +++ b/commands/life/Makefile @@ -0,0 +1,7 @@ +PROG= life +MAN= + +DPADD+= ${LIBCURSES} +LDADD+= -lcurses + +.include diff --git a/commands/simple/life.c b/commands/life/life.c similarity index 100% rename from commands/simple/life.c rename to commands/life/life.c diff --git a/commands/loadfont/Makefile b/commands/loadfont/Makefile new file mode 100644 index 000000000..39b865cf8 --- /dev/null +++ b/commands/loadfont/Makefile @@ -0,0 +1,4 @@ +PROG= loadfont +MAN= + +.include diff --git a/commands/ibm/loadfont.c b/commands/loadfont/loadfont.c similarity index 100% rename from commands/ibm/loadfont.c rename to commands/loadfont/loadfont.c diff --git a/commands/loadkeys/Makefile b/commands/loadkeys/Makefile new file mode 100644 index 000000000..edb2fb3fc --- /dev/null +++ b/commands/loadkeys/Makefile @@ -0,0 +1,5 @@ +PROG= loadkeys +BINDIR= /bin +MAN= + +.include diff --git a/commands/ibm/loadkeys.c b/commands/loadkeys/loadkeys.c similarity index 100% rename from commands/ibm/loadkeys.c rename to commands/loadkeys/loadkeys.c diff --git a/commands/loadramdisk/Makefile b/commands/loadramdisk/Makefile new file mode 100644 index 000000000..edecb68ee --- /dev/null +++ b/commands/loadramdisk/Makefile @@ -0,0 +1,4 @@ +PROG= loadramdisk +MAN= + +.include diff --git a/commands/simple/loadramdisk.c b/commands/loadramdisk/loadramdisk.c similarity index 100% rename from commands/simple/loadramdisk.c rename to commands/loadramdisk/loadramdisk.c diff --git a/commands/logger/Makefile b/commands/logger/Makefile new file mode 100644 index 000000000..e12d044ab --- /dev/null +++ b/commands/logger/Makefile @@ -0,0 +1,4 @@ +PROG= logger +MAN= + +.include diff --git a/commands/syslogd/logger.c b/commands/logger/logger.c similarity index 100% rename from commands/syslogd/logger.c rename to commands/logger/logger.c diff --git a/commands/login/Makefile b/commands/login/Makefile new file mode 100644 index 000000000..6d9a5432e --- /dev/null +++ b/commands/login/Makefile @@ -0,0 +1,4 @@ +PROG= login +MAN= + +.include diff --git a/commands/simple/login.c b/commands/login/login.c similarity index 100% rename from commands/simple/login.c rename to commands/login/login.c diff --git a/commands/look/Makefile b/commands/look/Makefile new file mode 100644 index 000000000..c038d231b --- /dev/null +++ b/commands/look/Makefile @@ -0,0 +1,4 @@ +PROG= look +MAN= + +.include diff --git a/commands/simple/look.c b/commands/look/look.c similarity index 100% rename from commands/simple/look.c rename to commands/look/look.c diff --git a/commands/lp/Makefile b/commands/lp/Makefile new file mode 100644 index 000000000..ba7f2b43f --- /dev/null +++ b/commands/lp/Makefile @@ -0,0 +1,4 @@ +PROG= lp +MAN= + +.include diff --git a/commands/simple/lp.c b/commands/lp/lp.c similarity index 100% rename from commands/simple/lp.c rename to commands/lp/lp.c diff --git a/commands/lpd/Makefile b/commands/lpd/Makefile new file mode 100644 index 000000000..82bc5f19f --- /dev/null +++ b/commands/lpd/Makefile @@ -0,0 +1,6 @@ +PROG= lpd +BINOWN= daemon +BINMODE= 4755 +MAN= + +.include diff --git a/commands/simple/lpd.c b/commands/lpd/lpd.c similarity index 100% rename from commands/simple/lpd.c rename to commands/lpd/lpd.c diff --git a/commands/ls/Makefile b/commands/ls/Makefile new file mode 100644 index 000000000..08eedb9c4 --- /dev/null +++ b/commands/ls/Makefile @@ -0,0 +1,5 @@ +PROG= ls +BINDIR= /bin +MAN= + +.include diff --git a/commands/simple/ls.c b/commands/ls/ls.c similarity index 100% rename from commands/simple/ls.c rename to commands/ls/ls.c diff --git a/commands/lspci/Makefile b/commands/lspci/Makefile new file mode 100644 index 000000000..638c31c3f --- /dev/null +++ b/commands/lspci/Makefile @@ -0,0 +1,4 @@ +PROG= lspci +MAN= + +.include diff --git a/commands/simple/lspci.c b/commands/lspci/lspci.c similarity index 100% rename from commands/simple/lspci.c rename to commands/lspci/lspci.c diff --git a/commands/m4/Makefile b/commands/m4/Makefile index 727efbdae..cdbd194ce 100644 --- a/commands/m4/Makefile +++ b/commands/m4/Makefile @@ -6,22 +6,9 @@ # -DDUFFCP #if you do not have fast memcpy in your library. # -CFLAGS = -DEXTENDED -O -D_POSIX_SOURCE -D_MINIX -CC = exec cc +PROG= m4 +SRCS= main.c eval.c serv.c look.c misc.c expr.c +CPPFLAGS+= -DEXTENDED +MAN= -OBJ = main.o eval.o serv.o look.o misc.o expr.o -INCL = mdef.h extr.h patchlevel.h - -all: m4 - -m4: $(OBJ) $(INCL) - cc -i -o m4 $(OBJ) - install -S 4kw m4 - -install: /usr/bin/m4 - -/usr/bin/m4: m4 - install -cs -o bin m4 $@ - -clean: - rm -f *.o m4 core *bak +.include diff --git a/commands/m4/build b/commands/m4/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/m4/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/mail/Makefile b/commands/mail/Makefile new file mode 100644 index 000000000..e4ed4f473 --- /dev/null +++ b/commands/mail/Makefile @@ -0,0 +1,5 @@ +PROG= mail +BINMODE= 4755 +MAN= + +.include diff --git a/commands/simple/mail.c b/commands/mail/mail.c similarity index 100% rename from commands/simple/mail.c rename to commands/mail/mail.c diff --git a/commands/make/Makefile b/commands/make/Makefile index 4f372146b..7ac93b337 100644 --- a/commands/make/Makefile +++ b/commands/make/Makefile @@ -1,54 +1,38 @@ -# $NetBSD: Makefile.boot,v 1.19 2009/01/24 11:59:39 dsl Exp $ -# -# a very simple makefile... -# -# You only want to use this if you aren't running NetBSD. -# -# modify MACHINE and MACHINE_ARCH as appropriate for your target architecture -# -#CC=gcc -O -g -CC=cc -CFLAGS=-g -Wall -DHAVE_SETENV -DHAVE_STRERROR -DHAVE_STRDUP -DHAVE_STRFTIME -DHAVE_VSNPRINTF -DUSE_SELECT -D_POSIX_SOURCE -D_MINIX +# $NetBSD: Makefile,v 1.49 2009/04/14 22:15:23 lukem Exp $ +# @(#)Makefile 5.2 (Berkeley) 12/28/90 -.c.o: - ${CC} ${CFLAGS} -c $< -o $@ +PROG= make +SRCS= arch.c buf.c compat.c cond.c dir.c for.c hash.c job.c main.c \ + make.c parse.c str.c suff.c targ.c trace.c var.c util.c +SRCS+= strlist.c +SRCS+= make_malloc.c +SRCS+= lstAppend.c lstAtEnd.c lstAtFront.c lstClose.c lstConcat.c \ + lstDatum.c lstDeQueue.c lstDestroy.c lstDupl.c lstEnQueue.c \ + lstFind.c lstFindFrom.c lstFirst.c lstForEach.c lstForEachFrom.c \ + lstInit.c lstInsert.c lstIsAtEnd.c lstIsEmpty.c lstLast.c \ + lstMember.c lstNext.c lstOpen.c lstRemove.c lstReplace.c lstSucc.c +SRCS+= lstPrev.c -MACHINE=i386 -MACHINE_ARCH=i386 -# tested on HP-UX 10.20 -#MAKE_MACHINE=hp700 -#MAKE_MACHINE_ARCH=hppa -CFLAGS+= -DTARGET_MACHINE=\"${MACHINE}\" \ + +# For MINIX +CPPFLAGS+= -g -Wall -DHAVE_SETENV -DHAVE_STRERROR -DHAVE_STRDUP \ + -DHAVE_STRFTIME -DHAVE_VSNPRINTF -DUSE_SELECT +MACHINE=${ARCH} +MACHINE_ARCH=${ARCH} +CPPFLAGS+= -DTARGET_MACHINE=\"${MACHINE}\" \ -DTARGET_MACHINE_ARCH=\"${MACHINE_ARCH}\" \ -DMAKE_MACHINE=\"${MACHINE}\" -LIBS= -OBJ=arch.o buf.o compat.o cond.o dir.o for.o hash.o job.o main.o make.o \ - make_malloc.o parse.o str.o strlist.o suff.o targ.o trace.o var.o util.o -LIBOBJ= lst.lib/lstAppend.o lst.lib/lstAtEnd.o lst.lib/lstAtFront.o \ - lst.lib/lstClose.o lst.lib/lstConcat.o lst.lib/lstDatum.o \ - lst.lib/lstDeQueue.o lst.lib/lstDestroy.o lst.lib/lstDupl.o \ - lst.lib/lstEnQueue.o lst.lib/lstFind.o lst.lib/lstFindFrom.o \ - lst.lib/lstFirst.o lst.lib/lstForEach.o lst.lib/lstForEachFrom.o \ - lst.lib/lstInit.o lst.lib/lstInsert.o lst.lib/lstIsAtEnd.o \ - lst.lib/lstIsEmpty.o lst.lib/lstLast.o lst.lib/lstMember.o \ - lst.lib/lstNext.o lst.lib/lstOpen.o lst.lib/lstRemove.o \ - lst.lib/lstReplace.o lst.lib/lstSucc.o lst.lib/lstPrev.o + .PATH: ${.CURDIR}/lst.lib -all: make +# .if make(obj) || make(clean) +# SUBDIR+= unit-tests +# .endif -make: ${OBJ} ${LIBOBJ} -# @echo 'make of make and make.0 started.' - ${CC} ${CFLAGS} ${OBJ} ${LIBOBJ} -o make ${LIBS} - @ls -l $@ -# nroff -h -man make.1 > make.0 -# @echo 'make of make and make.0 completed.' +.include +.include -install: /usr/bin/make - -/usr/bin/make: make - install -c -o bin make $@ - -clean: - rm -f ${OBJ} ${LIBOBJ} ${PORTOBJ} make +# A simple unit-test driver to help catch regressions +accept test: + cd ${.CURDIR}/unit-tests && ${.MAKE:S,^./,${.CURDIR}/,} TEST_MAKE=${TEST_MAKE:U${.OBJDIR}/${PROG:T}} ${.TARGET} diff --git a/commands/make/unit-tests/Makefile b/commands/make/unit-tests/Makefile index b3fd0a818..cbce37420 100644 --- a/commands/make/unit-tests/Makefile +++ b/commands/make/unit-tests/Makefile @@ -49,7 +49,7 @@ ${SUBFILES}: clean: rm -f *.out *.fail *.core -.include +.include TEST_MAKE?= ${.MAKE} diff --git a/commands/makewhatis/Makefile b/commands/makewhatis/Makefile new file mode 100644 index 000000000..9fb595155 --- /dev/null +++ b/commands/makewhatis/Makefile @@ -0,0 +1,4 @@ +SCRIPTS= makewhatis.sh +MAN= + +.include diff --git a/commands/scripts/makewhatis.sh b/commands/makewhatis/makewhatis.sh old mode 100755 new mode 100644 similarity index 100% rename from commands/scripts/makewhatis.sh rename to commands/makewhatis/makewhatis.sh diff --git a/commands/man/Makefile b/commands/man/Makefile new file mode 100644 index 000000000..1388ec18b --- /dev/null +++ b/commands/man/Makefile @@ -0,0 +1,4 @@ +PROG= man +MAN= + +.include diff --git a/commands/simple/man.c b/commands/man/man.c similarity index 100% rename from commands/simple/man.c rename to commands/man/man.c diff --git a/commands/mdb/Makefile b/commands/mdb/Makefile index 3b28461ef..6376e36bf 100644 --- a/commands/mdb/Makefile +++ b/commands/mdb/Makefile @@ -2,118 +2,28 @@ # Makefile for mdb # # -# Edit as indicated below. -# -USR =/usr -# -# (1) For Compiler and target system: -# -# -# For ANSI C and Minix 1.7.x 32-bit -# -CC =exec cc -LD =exec cc -LDFLAGS =-i -TARGET =mdb -STACK =200000 -# -# (2) If kernel and mm are not in "/usr/src" change this -# -SYSTEM =../.. -# -# (3) Select Options # # i) For GNU_EXEC Support, uncomment: # -FOR_GNU =gnu_sym.o -DEF_GNU =-DGNU_SUPPORT +FOR_GNU= gnu_sym.c +DEF_GNU= -DGNU_SUPPORT # # ii) For tracing of syscalls, uncomment: # -#FOR_SYSCALLS =syscalls.o decode.o ioctl.o -#DEF_SYSCALLS =-DSYSCALLS_SUPPORT +#FOR_SYSCALLS= syscalls.c decode.c ioctl.c +#DEF_SYSCALLS= -DSYSCALLS_SUPPORT # # iii) For no debugging of mdb, uncomment: # -#DEF_DEBUG =-DNDEBUG +#DEF_DEBUG= -DNDEBUG -EXTRA_OBJS =$(FOR_GNU) $(FOR_SYSCALLS) -EXTRA_DEFS =$(DEF_GNU) $(DEF_SYSCALLS) $(DEF_DEBUG) +EXTRA_SRCS= ${FOR_GNU} ${FOR_SYSCALLS} +EXTRA_DEFS= ${DEF_GNU} ${DEF_SYSCALLS} ${DEF_DEBUG} +CPPFLAGS+= -I${MINIXSRCDIR} -I${MINIXSRCDIR}/servers \ + ${EXTRA_DEFS} -all: $(TARGET) - -CFLAGS =-I$(SYSTEM) -I$(SYSTEM)/servers -I$(INCLUDE) -D_MINIX -D_POSIX_SOURCE $(EXTRA_DEFS) - -# For various included files or system files -# -INCLUDE =$(USR)/include -KERNEL =$(SYSTEM)/kernel -PTRACE =$(INCLUDE)/sys/ptrace.h - - -# Header files from system and kernel in "mdb.h" -# -SYSFILES= $(INCLUDE)/minix/config.h \ - $(INCLUDE)/minix/const.h \ - $(INCLUDE)/ansi.h \ - $(INCLUDE)/minix/type.h \ - $(INCLUDE)/limits.h \ - $(INCLUDE)/errno.h \ - $(INCLUDE)/sys/types.h \ - $(KERNEL)/const.h \ - $(KERNEL)/type.h \ - $(KERNEL)/proc.h - -# Common objects -# -OBJCOMMON =mdb.o mdbexp.o kernel.o sym.o trace.o core.o misc.o io.o - -# Common source -# -SRCCOMMON =mdb.c mdbexp.c kernel.o sym.c trace.c core.c misc.c io.c - -# Object files for PC -# -OBJPC =$(OBJCOMMON) mdbdis86.o - -# Source file -# -SRCPC =$(SRCCOMMON) mdbdis86.c - - -mdb: $(OBJPC) $(EXTRA_OBJS) - $(LD) $(LDFLAGS) -o mdb $(OBJPC) $(EXTRA_OBJS) - install -S $(STACK) mdb - -# -# Dependencies for objects -# -mdb.o: mdb.c mdb.h $(SYSFILES) proto.h -mdbdis86.o: mdbdis86.c mdb.h $(SYSFILES) proto.h -mdbexp.o: mdbexp.c mdb.h $(SYSFILES) proto.h -sym.o: sym.c mdb.h $(SYSFILES) proto.h -trace.o: trace.c mdb.h $(PTRACE) $(SYSFILES) proto.h -core.o: core.c mdb.h $(MMFILES) $(SYSFILES) proto.h -misc.o: misc.c mdb.h $(SYSFILES) proto.h -io.o: io.c mdb.h $(SYSFILES) proto.h - -syscalls.o: syscalls.c mdb.h $(SYSFILES) proto.h -decode.o: decode.c mdb.h $(INCLUDE)/minix/callnr.h $(SYSFILES) proto.h -ioctl.o: ioctl.c mdb.h $(SYSFILES) proto.h - -gnu_sym.o: gnu_sym.c mdb.h $(SYSFILES) proto.h - - -# -# install -# - -install: mdb - install -cs -o bin mdb /usr/bin - -install_man: mdb.1 - install -c -o bin mdb.1 /usr/man/man1 - -clean: - rm -f *.o mdb +SRCS= mdb.c mdbexp.c kernel.o sym.c trace.c core.c misc.c io.c +SRCS+= mdbdis86.c +SRCS+= ${EXTRA_SRCS} +.include diff --git a/commands/mdb/build b/commands/mdb/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/mdb/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/mesg/Makefile b/commands/mesg/Makefile new file mode 100644 index 000000000..029992d25 --- /dev/null +++ b/commands/mesg/Makefile @@ -0,0 +1,4 @@ +PROG= mesg +MAN= + +.include diff --git a/commands/simple/mesg.c b/commands/mesg/mesg.c similarity index 100% rename from commands/simple/mesg.c rename to commands/mesg/mesg.c diff --git a/commands/mined/Makefile b/commands/mined/Makefile index 2a97d81a2..7092ba20d 100644 --- a/commands/mined/Makefile +++ b/commands/mined/Makefile @@ -1,23 +1,8 @@ # Makefile for mined -CC = exec cc +PROG= mined +SRCS= mined1.c mined2.c +CPPFLAGS+= -wo +MAN= -CFLAGS = -O -wo -D_MINIX -D_POSIX_SOURCE - -OBJ = mined1.o mined2.o - -all: mined - -mined: $(OBJ) - $(CC) -i -o $@ $(OBJ) - install -S 64k $@ - -install: /usr/bin/mined - -/usr/bin/mined: mined - install -cs -o bin mined $@ - -$(OBJ): mined.h - -clean: - rm -f mined *.o *.s core *.bak +.include diff --git a/commands/mined/build b/commands/mined/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/mined/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/mixer/Makefile b/commands/mixer/Makefile new file mode 100644 index 000000000..fdfc78f87 --- /dev/null +++ b/commands/mixer/Makefile @@ -0,0 +1,7 @@ +PROG= mixer +MAN= + +DPADD+= ${LIBCURSES} +LDADD+= -lcurses + +.include diff --git a/commands/ibm/mixer.c b/commands/mixer/mixer.c similarity index 100% rename from commands/ibm/mixer.c rename to commands/mixer/mixer.c diff --git a/commands/mkdep/Makefile b/commands/mkdep/Makefile new file mode 100644 index 000000000..e93a17e44 --- /dev/null +++ b/commands/mkdep/Makefile @@ -0,0 +1,4 @@ +SCRIPTS= mkdep.sh +MAN= + +.include diff --git a/commands/scripts/mkdep.sh b/commands/mkdep/mkdep.sh similarity index 100% rename from commands/scripts/mkdep.sh rename to commands/mkdep/mkdep.sh diff --git a/commands/mkdir/Makefile b/commands/mkdir/Makefile new file mode 100644 index 000000000..e22f80fe6 --- /dev/null +++ b/commands/mkdir/Makefile @@ -0,0 +1,4 @@ +PROG= mkdir +MAN= + +.include diff --git a/commands/simple/mkdir.c b/commands/mkdir/mkdir.c similarity index 100% rename from commands/simple/mkdir.c rename to commands/mkdir/mkdir.c diff --git a/commands/mkdist/Makefile b/commands/mkdist/Makefile new file mode 100644 index 000000000..c096ca2d3 --- /dev/null +++ b/commands/mkdist/Makefile @@ -0,0 +1,4 @@ +SCRIPTS= mkdist.sh +MAN= + +.include diff --git a/commands/scripts/mkdist.sh b/commands/mkdist/mkdist.sh old mode 100755 new mode 100644 similarity index 100% rename from commands/scripts/mkdist.sh rename to commands/mkdist/mkdist.sh diff --git a/commands/mkfifo/Makefile b/commands/mkfifo/Makefile new file mode 100644 index 000000000..939efc0ed --- /dev/null +++ b/commands/mkfifo/Makefile @@ -0,0 +1,4 @@ +PROG= mkfifo +MAN= + +.include diff --git a/commands/simple/mkfifo.c b/commands/mkfifo/mkfifo.c similarity index 100% rename from commands/simple/mkfifo.c rename to commands/mkfifo/mkfifo.c diff --git a/commands/mkfs/Makefile b/commands/mkfs/Makefile new file mode 100644 index 000000000..eb3c040ab --- /dev/null +++ b/commands/mkfs/Makefile @@ -0,0 +1,5 @@ +PROG= mkfs +CPPFLAGS+= -I${MINIXSRCDIR}/servers +MAN= + +.include diff --git a/commands/simple/mkfs.c b/commands/mkfs/mkfs.c similarity index 99% rename from commands/simple/mkfs.c rename to commands/mkfs/mkfs.c index 7e7dd49d4..19cb22c79 100644 --- a/commands/simple/mkfs.c +++ b/commands/mkfs/mkfs.c @@ -25,7 +25,7 @@ #include #include #include -#include "../../servers/mfs/const.h" +#include "mfs/const.h" #if (MACHINE == IBM_PC) #include #include @@ -37,9 +37,9 @@ #undef EXTERN #define EXTERN /* get rid of EXTERN by making it null */ -#include "../../servers/mfs/super.h" -#include "../../servers/mfs/type.h" -#include "../../servers/mfs/inode.h" +#include "mfs/super.h" +#include "mfs/type.h" +#include "mfs/inode.h" #include #ifndef max diff --git a/commands/mknod/Makefile b/commands/mknod/Makefile new file mode 100644 index 000000000..8fd1b28a3 --- /dev/null +++ b/commands/mknod/Makefile @@ -0,0 +1,4 @@ +PROG= mknod +MAN= + +.include diff --git a/commands/simple/mknod.c b/commands/mknod/mknod.c similarity index 100% rename from commands/simple/mknod.c rename to commands/mknod/mknod.c diff --git a/commands/mkproto/Makefile b/commands/mkproto/Makefile new file mode 100644 index 000000000..aae445f7c --- /dev/null +++ b/commands/mkproto/Makefile @@ -0,0 +1,4 @@ +PROG= mkproto +MAN= + +.include diff --git a/commands/simple/mkproto.c b/commands/mkproto/mkproto.c similarity index 100% rename from commands/simple/mkproto.c rename to commands/mkproto/mkproto.c diff --git a/commands/modem/Makefile b/commands/modem/Makefile new file mode 100644 index 000000000..5ff37d6c3 --- /dev/null +++ b/commands/modem/Makefile @@ -0,0 +1,4 @@ +PROG= modem +MAN= + +.include diff --git a/commands/simple/modem.c b/commands/modem/modem.c similarity index 100% rename from commands/simple/modem.c rename to commands/modem/modem.c diff --git a/commands/mount/Makefile b/commands/mount/Makefile new file mode 100644 index 000000000..9ffcd57a9 --- /dev/null +++ b/commands/mount/Makefile @@ -0,0 +1,7 @@ +PROG= mount +CPPFLAGS+= -I${MINIXSRCDIR}/servers +BINDIR= /bin +BINMODE= 4755 +MAN= + +.include diff --git a/commands/simple/mount.c b/commands/mount/mount.c similarity index 98% rename from commands/simple/mount.c rename to commands/mount/mount.c index abbd533e0..38c2dd77c 100644 --- a/commands/simple/mount.c +++ b/commands/mount/mount.c @@ -14,7 +14,7 @@ #include #include #include -#include "../../servers/mfs/const.h" +#include "mfs/const.h" #define MINIX_FS_TYPE "mfs" diff --git a/commands/mt/Makefile b/commands/mt/Makefile new file mode 100644 index 000000000..beff6bce8 --- /dev/null +++ b/commands/mt/Makefile @@ -0,0 +1,4 @@ +PROG= mt +MAN= + +.include diff --git a/commands/simple/mt.c b/commands/mt/mt.c similarity index 100% rename from commands/simple/mt.c rename to commands/mt/mt.c diff --git a/commands/netconf/Makefile b/commands/netconf/Makefile new file mode 100644 index 000000000..8fe58ea06 --- /dev/null +++ b/commands/netconf/Makefile @@ -0,0 +1,5 @@ +SCRIPTS= netconf.sh +BINDIR= /bin +MAN= + +.include diff --git a/commands/scripts/netconf.sh b/commands/netconf/netconf.sh old mode 100755 new mode 100644 similarity index 100% rename from commands/scripts/netconf.sh rename to commands/netconf/netconf.sh diff --git a/commands/newroot/Makefile b/commands/newroot/Makefile new file mode 100644 index 000000000..a9aa24e53 --- /dev/null +++ b/commands/newroot/Makefile @@ -0,0 +1,4 @@ +PROG= newroot +MAN= + +.include diff --git a/commands/simple/newroot.c b/commands/newroot/newroot.c similarity index 100% rename from commands/simple/newroot.c rename to commands/newroot/newroot.c diff --git a/commands/nice/Makefile b/commands/nice/Makefile new file mode 100644 index 000000000..0a74c5794 --- /dev/null +++ b/commands/nice/Makefile @@ -0,0 +1,4 @@ +PROG= nice +MAN= + +.include diff --git a/commands/simple/nice.c b/commands/nice/nice.c similarity index 100% rename from commands/simple/nice.c rename to commands/nice/nice.c diff --git a/commands/nm/Makefile b/commands/nm/Makefile new file mode 100644 index 000000000..eec0c1c84 --- /dev/null +++ b/commands/nm/Makefile @@ -0,0 +1,4 @@ +PROG= nm +MAN= + +.include diff --git a/commands/simple/nm.c b/commands/nm/nm.c similarity index 100% rename from commands/simple/nm.c rename to commands/nm/nm.c diff --git a/commands/nohup/Makefile b/commands/nohup/Makefile new file mode 100644 index 000000000..e54770f35 --- /dev/null +++ b/commands/nohup/Makefile @@ -0,0 +1,4 @@ +PROG= nohup +MAN= + +.include diff --git a/commands/simple/nohup.c b/commands/nohup/nohup.c similarity index 100% rename from commands/simple/nohup.c rename to commands/nohup/nohup.c diff --git a/commands/nonamed/Makefile b/commands/nonamed/Makefile new file mode 100644 index 000000000..4bfc49000 --- /dev/null +++ b/commands/nonamed/Makefile @@ -0,0 +1,4 @@ +PROG= nonamed +MAN= + +.include diff --git a/commands/simple/nonamed.c b/commands/nonamed/nonamed.c similarity index 100% rename from commands/simple/nonamed.c rename to commands/nonamed/nonamed.c diff --git a/commands/od/Makefile b/commands/od/Makefile new file mode 100644 index 000000000..e3960c0f7 --- /dev/null +++ b/commands/od/Makefile @@ -0,0 +1,4 @@ +PROG= od +MAN= + +.include diff --git a/commands/simple/od.c b/commands/od/od.c similarity index 100% rename from commands/simple/od.c rename to commands/od/od.c diff --git a/commands/packit/Makefile b/commands/packit/Makefile new file mode 100644 index 000000000..272790ce1 --- /dev/null +++ b/commands/packit/Makefile @@ -0,0 +1,4 @@ +SCRIPTS= packit.sh +MAN= + +.include diff --git a/commands/scripts/packit.sh b/commands/packit/packit.sh similarity index 100% rename from commands/scripts/packit.sh rename to commands/packit/packit.sh diff --git a/commands/packman/Makefile b/commands/packman/Makefile new file mode 100644 index 000000000..d31a06d36 --- /dev/null +++ b/commands/packman/Makefile @@ -0,0 +1,4 @@ +SCRIPTS= packman.sh +MAN= + +.include diff --git a/commands/scripts/packman.sh b/commands/packman/packman.sh similarity index 100% rename from commands/scripts/packman.sh rename to commands/packman/packman.sh diff --git a/commands/part/Makefile b/commands/part/Makefile new file mode 100644 index 000000000..d8fe20c61 --- /dev/null +++ b/commands/part/Makefile @@ -0,0 +1,4 @@ +PROG= part +MAN= + +.include diff --git a/commands/ibm/part.c b/commands/part/part.c similarity index 100% rename from commands/ibm/part.c rename to commands/part/part.c diff --git a/commands/partition/Makefile b/commands/partition/Makefile new file mode 100644 index 000000000..813c531ba --- /dev/null +++ b/commands/partition/Makefile @@ -0,0 +1,4 @@ +PROG= partition +MAN= + +.include diff --git a/commands/ibm/partition.c b/commands/partition/partition.c similarity index 100% rename from commands/ibm/partition.c rename to commands/partition/partition.c diff --git a/commands/passwd/Makefile b/commands/passwd/Makefile new file mode 100644 index 000000000..69d98acf5 --- /dev/null +++ b/commands/passwd/Makefile @@ -0,0 +1,8 @@ +PROG= passwd +BINMODE= 4755 +MAN= + +LINKS+= ${BINDIR}/passwd ${BINDIR}/chsh +LINKS+= ${BINDIR}/passwd ${BINDIR}/chfn + +.include diff --git a/commands/simple/passwd.c b/commands/passwd/passwd.c similarity index 100% rename from commands/simple/passwd.c rename to commands/passwd/passwd.c diff --git a/commands/paste/Makefile b/commands/paste/Makefile new file mode 100644 index 000000000..8cabf2777 --- /dev/null +++ b/commands/paste/Makefile @@ -0,0 +1,4 @@ +PROG= paste +MAN= + +.include diff --git a/commands/simple/paste.c b/commands/paste/paste.c similarity index 100% rename from commands/simple/paste.c rename to commands/paste/paste.c diff --git a/commands/patch/Makefile b/commands/patch/Makefile index ef0528783..0d5758c2b 100644 --- a/commands/patch/Makefile +++ b/commands/patch/Makefile @@ -1,28 +1,8 @@ # Makefile for patch -CFLAGS= -O -DVOIDSIG -wo -D_MINIX -D_POSIX_SOURCE -DSMALL +PROG= patch +SRCS= patch.c pch.c inp.c util.c version.c +CPPFLAGS+= -DVOIDSIG -wo -DSMALL +MAN= -CC = exec cc - -OBJ = patch.o pch.o inp.o util.o version.o - -all: patch - -patch: $(OBJ) - cc -i -o patch $(OBJ) - install -S 1M patch - -install: /usr/bin/patch - -/usr/bin/patch: patch - install -cs -o bin patch $@ - -patch.o: config.h common.h patch.c inp.h pch.h util.h version.h -pch.o: config.h common.h pch.c pch.h util.h -inp.o: config.h common.h inp.c inp.h util.h -util.o: config.h common.h util.c util.h -version.o: config.h common.h version.c version.h patchlevel.h util.h - - -clean: - rm -f *.bak *.o *.s core patch +.include diff --git a/commands/patch/build b/commands/patch/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/patch/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/pax/Makefile b/commands/pax/Makefile index 7a7c2ad2c..9292832d7 100644 --- a/commands/pax/Makefile +++ b/commands/pax/Makefile @@ -32,10 +32,9 @@ SRCS= ar_io.c ar_subs.c buf_subs.c cache.c cpio.c file_subs.c ftree.c \ MAN= pax.1 tar.1 cpio.1 -BINDIR?=/usr/bin LINKS+= ${BINDIR}/pax ${BINDIR}/tar LINKS+= ${BINDIR}/pax ${BINDIR}/cpio -CFLAGS+= -O -D_POSIX_SOURCE -DNET2_STAT=1 -D_MINIX=1 +CPPFLAGS+= -DNET2_STAT=1 .include diff --git a/commands/ping/Makefile b/commands/ping/Makefile new file mode 100644 index 000000000..a948e21a2 --- /dev/null +++ b/commands/ping/Makefile @@ -0,0 +1,5 @@ +PROG= ping +BINMODE= 4755 +MAN= + +.include diff --git a/commands/simple/ping.c b/commands/ping/ping.c similarity index 100% rename from commands/simple/ping.c rename to commands/ping/ping.c diff --git a/commands/playwave/Makefile b/commands/playwave/Makefile new file mode 100644 index 000000000..37ad5a3b1 --- /dev/null +++ b/commands/playwave/Makefile @@ -0,0 +1,4 @@ +PROG= playwave +MAN= + +.include diff --git a/commands/ibm/playwave.c b/commands/playwave/playwave.c similarity index 100% rename from commands/ibm/playwave.c rename to commands/playwave/playwave.c diff --git a/commands/postinstall/Makefile b/commands/postinstall/Makefile new file mode 100644 index 000000000..4f46bdfa4 --- /dev/null +++ b/commands/postinstall/Makefile @@ -0,0 +1,4 @@ +SCRIPTS= postinstall.sh +MAN= + +.include diff --git a/commands/scripts/postinstall.sh b/commands/postinstall/postinstall.sh similarity index 100% rename from commands/scripts/postinstall.sh rename to commands/postinstall/postinstall.sh diff --git a/commands/postmort/Makefile b/commands/postmort/Makefile new file mode 100644 index 000000000..54601ddca --- /dev/null +++ b/commands/postmort/Makefile @@ -0,0 +1,5 @@ +PROG= postmort +CPPFLAGS+= -I${MINIXSRCDIR} -I${MINIXSRCDIR}/servers +MAN= + +.include diff --git a/commands/ibm/postmort.c b/commands/postmort/postmort.c similarity index 99% rename from commands/ibm/postmort.c rename to commands/postmort/postmort.c index 4164307b1..808f50a14 100644 --- a/commands/ibm/postmort.c +++ b/commands/postmort/postmort.c @@ -34,11 +34,11 @@ #undef EXTERN /* defined this */ #define EXTERN /* so we get proc & mproc */ #include -#include "../../kernel/const.h" -#include "../../kernel/type.h" -#include "../../kernel/proc.h" +#include "kernel/const.h" +#include "kernel/type.h" +#include "kernel/proc.h" #undef printf /* kernel's const.h defined this */ -#include "../../servers/pm/mproc.h" +#include "pm/mproc.h" #include #include diff --git a/commands/poweroff/Makefile b/commands/poweroff/Makefile new file mode 100644 index 000000000..e3d54d43e --- /dev/null +++ b/commands/poweroff/Makefile @@ -0,0 +1,4 @@ +SCRIPTS= poweroff.sh +MAN= + +.include diff --git a/commands/scripts/poweroff.sh b/commands/poweroff/poweroff.sh similarity index 100% rename from commands/scripts/poweroff.sh rename to commands/poweroff/poweroff.sh diff --git a/commands/pr/Makefile b/commands/pr/Makefile new file mode 100644 index 000000000..577582ada --- /dev/null +++ b/commands/pr/Makefile @@ -0,0 +1,4 @@ +PROG= pr +MAN= + +.include diff --git a/commands/simple/pr.c b/commands/pr/pr.c similarity index 100% rename from commands/simple/pr.c rename to commands/pr/pr.c diff --git a/commands/pr_routes/Makefile b/commands/pr_routes/Makefile new file mode 100644 index 000000000..193c33e5c --- /dev/null +++ b/commands/pr_routes/Makefile @@ -0,0 +1,5 @@ +PROG= pr_routes +BINMODE= 4755 +MAN= + +.include diff --git a/commands/simple/pr_routes.c b/commands/pr_routes/pr_routes.c similarity index 100% rename from commands/simple/pr_routes.c rename to commands/pr_routes/pr_routes.c diff --git a/commands/prep/Makefile b/commands/prep/Makefile new file mode 100644 index 000000000..0250ede19 --- /dev/null +++ b/commands/prep/Makefile @@ -0,0 +1,4 @@ +PROG= prep +MAN= + +.include diff --git a/commands/simple/prep.c b/commands/prep/prep.c similarity index 100% rename from commands/simple/prep.c rename to commands/prep/prep.c diff --git a/commands/printf/Makefile b/commands/printf/Makefile new file mode 100644 index 000000000..45013da6f --- /dev/null +++ b/commands/printf/Makefile @@ -0,0 +1,4 @@ +PROG= printf +MAN= + +.include diff --git a/commands/simple/printf.c b/commands/printf/printf.c similarity index 100% rename from commands/simple/printf.c rename to commands/printf/printf.c diff --git a/commands/printroot/Makefile b/commands/printroot/Makefile new file mode 100644 index 000000000..63939c75e --- /dev/null +++ b/commands/printroot/Makefile @@ -0,0 +1,5 @@ +PROG= printroot +BINDIR= /bin +MAN= + +.include diff --git a/commands/simple/printroot.c b/commands/printroot/printroot.c similarity index 100% rename from commands/simple/printroot.c rename to commands/printroot/printroot.c diff --git a/commands/profile/Makefile b/commands/profile/Makefile index 2fa766aaa..bcf6eef45 100644 --- a/commands/profile/Makefile +++ b/commands/profile/Makefile @@ -1,29 +1,7 @@ # Makefile for profile and profalyze.pl -CC=exec cc - -all: profile sprofalyze.pl cprofalyze.pl - -profile: profile.c - $(CC) -o $@ profile.c - install -S 65m $@ -sprofalyze.pl: - install $@ - -cprofalyze.pl: - install $@ - -install: /usr/bin/profile /usr/bin/sprofalyze.pl /usr/bin/cprofalyze.pl - -/usr/bin/profile: profile - install -cs -o bin $? $@ - -/usr/bin/sprofalyze.pl: sprofalyze.pl - install -o bin $? $@ - -/usr/bin/cprofalyze.pl: cprofalyze.pl - install -o bin $? $@ - -clean: - rm -f *.o core *.bak profile +PROG= profile +SCRIPTS= sprofalyze.pl cprofalyze.pl +MAN= +.include diff --git a/commands/profile/profile.c b/commands/profile/profile.c index c987a3e66..a91538b5a 100644 --- a/commands/profile/profile.c +++ b/commands/profile/profile.c @@ -7,9 +7,6 @@ * 14 Aug, 2006 Created (Rogier Meurs) */ -#define SPROFILE 1 -#define CPROFILE 1 - #include #include #include diff --git a/commands/progressbar/Makefile b/commands/progressbar/Makefile new file mode 100644 index 000000000..cb6efea04 --- /dev/null +++ b/commands/progressbar/Makefile @@ -0,0 +1,4 @@ +PROG= progressbar +MAN= + +.include diff --git a/commands/simple/progressbar.c b/commands/progressbar/progressbar.c similarity index 100% rename from commands/simple/progressbar.c rename to commands/progressbar/progressbar.c diff --git a/commands/proto/Makefile b/commands/proto/Makefile new file mode 100644 index 000000000..3626141a5 --- /dev/null +++ b/commands/proto/Makefile @@ -0,0 +1,4 @@ +PROG= proto +MAN= + +.include diff --git a/commands/simple/proto.c b/commands/proto/proto.c similarity index 100% rename from commands/simple/proto.c rename to commands/proto/proto.c diff --git a/commands/ps/Makefile b/commands/ps/Makefile index 77b29ce75..f79d1e116 100644 --- a/commands/ps/Makefile +++ b/commands/ps/Makefile @@ -1,25 +1,9 @@ # Makefile for the process status utility. # -u=/usr -CC= exec cc -CFLAGS= -O -D_MINIX -D_POSIX_SOURCE -MAKE= exec make -$(MAKEFLAGS) -all: ps +PROG= ps +CPPFLAGS+= -I${MINIXSRCDIR} -I${MINIXSRCDIR}/servers +BINMODE= 4755 +MAN= -# process status utility -ps: ps.c /usr/include/minix/config.h /usr/include/minix/const.h \ - ../../kernel/const.h ../../kernel/type.h \ - ../../kernel/proc.h ../../servers/pm/mproc.h \ - ../../servers/vfs/fproc.h ../../servers/mfs/const.h - $(CC) -i $(CFLAGS) -o $@ ps.c - install -S 32kw $@ -install: /usr/bin/ps -/usr/bin/ps: ps - install -cs -o root -m 4755 $? $@ - - - -# clean up compile results -clean: - rm -f *.bak ps +.include diff --git a/commands/ps/build b/commands/ps/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/ps/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/ps/ps.c b/commands/ps/ps.c index 2fabd0631..2c1fcb02a 100644 --- a/commands/ps/ps.c +++ b/commands/ps/ps.c @@ -79,15 +79,15 @@ #include #include -#include "../../kernel/const.h" -#include "../../kernel/type.h" -#include "../../kernel/proc.h" +#include "kernel/const.h" +#include "kernel/type.h" +#include "kernel/proc.h" -#include "../../servers/pm/mproc.h" -#include "../../servers/pm/const.h" -#include "../../servers/vfs/fproc.h" -#include "../../servers/vfs/const.h" -#include "../../servers/mfs/const.h" +#include "pm/mproc.h" +#include "pm/const.h" +#include "vfs/fproc.h" +#include "vfs/const.h" +#include "mfs/const.h" /*----- ps's local stuff below this line ------*/ diff --git a/commands/pwd/Makefile b/commands/pwd/Makefile new file mode 100644 index 000000000..27fe9fe29 --- /dev/null +++ b/commands/pwd/Makefile @@ -0,0 +1,5 @@ +PROG= pwd +BINDIR= /bin +MAN= + +.include diff --git a/commands/simple/pwd.c b/commands/pwd/pwd.c similarity index 100% rename from commands/simple/pwd.c rename to commands/pwd/pwd.c diff --git a/commands/pwdauth/Makefile b/commands/pwdauth/Makefile new file mode 100644 index 000000000..f3c98a5be --- /dev/null +++ b/commands/pwdauth/Makefile @@ -0,0 +1,6 @@ +PROG= pwdauth +BINDIR= /usr/lib +BINMODE= 4755 +MAN= + +.include diff --git a/commands/simple/pwdauth.c b/commands/pwdauth/pwdauth.c similarity index 100% rename from commands/simple/pwdauth.c rename to commands/pwdauth/pwdauth.c diff --git a/commands/ramdisk/Makefile b/commands/ramdisk/Makefile new file mode 100644 index 000000000..3d6e5f442 --- /dev/null +++ b/commands/ramdisk/Makefile @@ -0,0 +1,4 @@ +PROG= ramdisk +MAN= + +.include diff --git a/commands/simple/ramdisk.c b/commands/ramdisk/ramdisk.c similarity index 100% rename from commands/simple/ramdisk.c rename to commands/ramdisk/ramdisk.c diff --git a/commands/rarpd/Makefile b/commands/rarpd/Makefile new file mode 100644 index 000000000..99922c80a --- /dev/null +++ b/commands/rarpd/Makefile @@ -0,0 +1,4 @@ +PROG= rarpd +MAN= + +.include diff --git a/commands/simple/rarpd.c b/commands/rarpd/rarpd.c similarity index 100% rename from commands/simple/rarpd.c rename to commands/rarpd/rarpd.c diff --git a/commands/rawspeed/Makefile b/commands/rawspeed/Makefile new file mode 100644 index 000000000..f55461f44 --- /dev/null +++ b/commands/rawspeed/Makefile @@ -0,0 +1,4 @@ +PROG= rawspeed +MAN= + +.include diff --git a/commands/simple/rawspeed.c b/commands/rawspeed/rawspeed.c similarity index 100% rename from commands/simple/rawspeed.c rename to commands/rawspeed/rawspeed.c diff --git a/commands/rcp/Makefile b/commands/rcp/Makefile new file mode 100644 index 000000000..99ba5413b --- /dev/null +++ b/commands/rcp/Makefile @@ -0,0 +1,4 @@ +PROG= rcp +MAN= + +.include diff --git a/commands/simple/rcp.c b/commands/rcp/rcp.c similarity index 100% rename from commands/simple/rcp.c rename to commands/rcp/rcp.c diff --git a/commands/rdate/Makefile b/commands/rdate/Makefile new file mode 100644 index 000000000..792d783db --- /dev/null +++ b/commands/rdate/Makefile @@ -0,0 +1,4 @@ +PROG= rdate +MAN= + +.include diff --git a/commands/simple/rdate.c b/commands/rdate/rdate.c similarity index 100% rename from commands/simple/rdate.c rename to commands/rdate/rdate.c diff --git a/commands/readall/Makefile b/commands/readall/Makefile new file mode 100644 index 000000000..a6cafa65b --- /dev/null +++ b/commands/readall/Makefile @@ -0,0 +1,4 @@ +PROG= readall +MAN= + +.include diff --git a/commands/simple/readall.c b/commands/readall/readall.c similarity index 100% rename from commands/simple/readall.c rename to commands/readall/readall.c diff --git a/commands/readclock/Makefile b/commands/readclock/Makefile new file mode 100644 index 000000000..4f4c6c929 --- /dev/null +++ b/commands/readclock/Makefile @@ -0,0 +1,5 @@ +SCRIPTS= readclock.sh +BINDIR= /bin +MAN= + +.include diff --git a/commands/scripts/readclock.sh b/commands/readclock/readclock.sh similarity index 100% rename from commands/scripts/readclock.sh rename to commands/readclock/readclock.sh diff --git a/commands/readfs/Makefile b/commands/readfs/Makefile new file mode 100644 index 000000000..aa6ba15c0 --- /dev/null +++ b/commands/readfs/Makefile @@ -0,0 +1,5 @@ +PROG= readfs +CPPFLAGS+= -I${MINIXSRCDIR}/servers +MAN= + +.include diff --git a/commands/simple/readfs.c b/commands/readfs/readfs.c similarity index 99% rename from commands/simple/readfs.c rename to commands/readfs/readfs.c index 77f4d8cd7..8f8a7bb40 100644 --- a/commands/simple/readfs.c +++ b/commands/readfs/readfs.c @@ -41,10 +41,10 @@ #include #include #include -#include "../../servers/mfs/const.h" -#include "../../servers/mfs/type.h" -#include "../../servers/mfs/buf.h" -#include "../../servers/mfs/super.h" +#include "mfs/const.h" +#include "mfs/type.h" +#include "mfs/buf.h" +#include "mfs/super.h" #undef printf /* Definition used only in the kernel */ #include diff --git a/commands/reboot/Makefile b/commands/reboot/Makefile index d10a98733..2dde81bdb 100644 --- a/commands/reboot/Makefile +++ b/commands/reboot/Makefile @@ -1,43 +1,10 @@ # Makefile for shutdown / halt / reboot. -CFLAGS=$(OPT) -D_MINIX -D_POSIX_SOURCE -LDFLAGS=-i -CC=exec cc +PROGS= shutdown halt +SRCS.shutdown= shutdown.c sh_wall.c log.c +SRCS.halt= halt.c log.c +LINKS+= ${BINDIR}/halt ${BINDIR}/reboot +MAN.shutdown= +MAN.halt= -PROGRAMS= shutdown halt tinyhalt -MANUALS= shutdown.8 halt.8 reboot.2 reboot.8 - -all: $(PROGRAMS) - -shutdown: shutdown.o sh_wall.o log.o - $(CC) $(LDFLAGS) -o shutdown shutdown.o sh_wall.o log.o - install -S 4kw $@ - -halt: halt.o log.o - $(CC) $(LDFLAGS) -o halt halt.o log.o - install -S 4kw $@ - -tinyhalt: tinyhalt.c - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $? - install -S 4kw $@ - -install: /usr/bin/halt /usr/bin/reboot /usr/bin/shutdown \ - /bin/halt /bin/reboot - -/usr/bin/halt: halt - install -cs -o root -g operator -m 744 $? $@ - -/usr/bin/reboot: /usr/bin/halt - install -l h $? $@ - -/usr/bin/shutdown: shutdown - install -cs -o root -g operator -m 4754 $? $@ - -/bin/halt: tinyhalt - install -cs -o root -g operator -m 744 $? $@ - -/bin/reboot: /bin/halt - install -l h $? $@ - -clean: - rm -f *.o a.out core $(PROGRAMS) +.include diff --git a/commands/reboot/build b/commands/reboot/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/reboot/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/recwave/Makefile b/commands/recwave/Makefile new file mode 100644 index 000000000..ff0508b6f --- /dev/null +++ b/commands/recwave/Makefile @@ -0,0 +1,4 @@ +PROG= recwave +MAN= + +.include diff --git a/commands/ibm/recwave.c b/commands/recwave/recwave.c similarity index 100% rename from commands/ibm/recwave.c rename to commands/recwave/recwave.c diff --git a/commands/remsync/Makefile b/commands/remsync/Makefile new file mode 100644 index 000000000..b94cdc855 --- /dev/null +++ b/commands/remsync/Makefile @@ -0,0 +1,4 @@ +PROG= remsync +MAN= + +.include diff --git a/commands/simple/remsync.c b/commands/remsync/remsync.c similarity index 100% rename from commands/simple/remsync.c rename to commands/remsync/remsync.c diff --git a/commands/repartition/Makefile b/commands/repartition/Makefile new file mode 100644 index 000000000..d97bafd4c --- /dev/null +++ b/commands/repartition/Makefile @@ -0,0 +1,4 @@ +PROG= repartition +MAN= + +.include diff --git a/commands/ibm/repartition.c b/commands/repartition/repartition.c similarity index 100% rename from commands/ibm/repartition.c rename to commands/repartition/repartition.c diff --git a/commands/rev/Makefile b/commands/rev/Makefile new file mode 100644 index 000000000..5e68f4532 --- /dev/null +++ b/commands/rev/Makefile @@ -0,0 +1,4 @@ +PROG= rev +MAN= + +.include diff --git a/commands/simple/rev.c b/commands/rev/rev.c similarity index 100% rename from commands/simple/rev.c rename to commands/rev/rev.c diff --git a/commands/rget/Makefile b/commands/rget/Makefile new file mode 100644 index 000000000..4cfde77c9 --- /dev/null +++ b/commands/rget/Makefile @@ -0,0 +1,6 @@ +PROG= rget +MAN= + +LINKS+= ${BINDIR}/rget ${BINDIR}/rput + +.include diff --git a/commands/simple/rget.c b/commands/rget/rget.c similarity index 100% rename from commands/simple/rget.c rename to commands/rget/rget.c diff --git a/commands/rlogin/Makefile b/commands/rlogin/Makefile new file mode 100644 index 000000000..6a702ab1f --- /dev/null +++ b/commands/rlogin/Makefile @@ -0,0 +1,4 @@ +PROG= rlogin +MAN= + +.include diff --git a/commands/simple/rlogin.c b/commands/rlogin/rlogin.c similarity index 100% rename from commands/simple/rlogin.c rename to commands/rlogin/rlogin.c diff --git a/commands/rlogind/Makefile b/commands/rlogind/Makefile index d94df979d..5547a1fdc 100644 --- a/commands/rlogind/Makefile +++ b/commands/rlogind/Makefile @@ -1,24 +1,7 @@ # Makefile for rlogind. -CFLAGS = $(OPT) -D_MINIX -CC = exec cc -LDFLAGS = +PROG= in.rlogind +SRCS= rlogind.c setup.c +MAN= -all: rlogind - -OBJ= rlogind.o setup.o - -rlogind: $(OBJ) - $(CC) $(LDFLAGS) -o $@ $(OBJ) - install -S 8kw $@ - -install: /usr/bin/in.rlogind - -/usr/bin/in.rlogind: rlogind - install -c $? $@ - -clean: - rm -f *.o rlogind core a.out - -# Dependencies. -$(OBJ): rlogind.h +.include diff --git a/commands/rlogind/build b/commands/rlogind/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/rlogind/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/rmdir/Makefile b/commands/rmdir/Makefile new file mode 100644 index 000000000..6ffc42664 --- /dev/null +++ b/commands/rmdir/Makefile @@ -0,0 +1,4 @@ +PROG= rmdir +MAN= + +.include diff --git a/commands/simple/rmdir.c b/commands/rmdir/rmdir.c similarity index 100% rename from commands/simple/rmdir.c rename to commands/rmdir/rmdir.c diff --git a/commands/rotate/Makefile b/commands/rotate/Makefile new file mode 100644 index 000000000..cf6098f2a --- /dev/null +++ b/commands/rotate/Makefile @@ -0,0 +1,4 @@ +SCRIPTS= rotate.sh +MAN= + +.include diff --git a/commands/scripts/rotate.sh b/commands/rotate/rotate.sh old mode 100755 new mode 100644 similarity index 100% rename from commands/scripts/rotate.sh rename to commands/rotate/rotate.sh diff --git a/commands/rsh/Makefile b/commands/rsh/Makefile new file mode 100644 index 000000000..9b97026f0 --- /dev/null +++ b/commands/rsh/Makefile @@ -0,0 +1,4 @@ +PROG= rsh +MAN= + +.include diff --git a/commands/simple/rsh.c b/commands/rsh/rsh.c similarity index 100% rename from commands/simple/rsh.c rename to commands/rsh/rsh.c diff --git a/commands/rshd/Makefile b/commands/rshd/Makefile new file mode 100644 index 000000000..3984bf1d4 --- /dev/null +++ b/commands/rshd/Makefile @@ -0,0 +1,5 @@ +PROG= in.rshd +SRCS= rshd.c +MAN= + +.include diff --git a/commands/simple/in.rshd.c b/commands/rshd/rshd.c similarity index 100% rename from commands/simple/in.rshd.c rename to commands/rshd/rshd.c diff --git a/commands/screendump/Makefile b/commands/screendump/Makefile new file mode 100644 index 000000000..328fb7d36 --- /dev/null +++ b/commands/screendump/Makefile @@ -0,0 +1,4 @@ +PROG= screendump +MAN= + +.include diff --git a/commands/ibm/screendump.c b/commands/screendump/screendump.c similarity index 100% rename from commands/ibm/screendump.c rename to commands/screendump/screendump.c diff --git a/commands/scripts/Makefile b/commands/scripts/Makefile deleted file mode 100644 index 21d94abf2..000000000 --- a/commands/scripts/Makefile +++ /dev/null @@ -1,192 +0,0 @@ -# Makefile for cmd/scripts. - -CFLAGS = -D_MINIX -D_POSIX_SOURCE -CCLD = $(CC) -i $(CFLAGS) -MAKE = exec make -$(MAKEFLAGS) install - -all: # Does nothing - -install: usr root - -# Commands on the /usr partition. -usr: \ - /usr/bin/DESCRIBE \ - /usr/bin/M \ - /usr/bin/U \ - /usr/bin/MAKEDEV \ - /usr/bin/bigmake \ - /usr/bin/adduser \ - /usr/bin/binpackage \ - /usr/bin/binpackages \ - /usr/bin/cd \ - /usr/bin/[ \ - /usr/bin/command \ - /usr/bin/easypack \ - /usr/bin/echo \ - /usr/bin/expr \ - /usr/bin/false \ - /usr/bin/getopts \ - /usr/bin/read \ - /usr/bin/test \ - /usr/bin/true \ - /usr/bin/umask \ - /usr/bin/wait \ - /usr/bin/checkhier \ - /usr/bin/clear \ - /usr/bin/clr \ - /usr/bin/makewhatis \ - /usr/bin/mkdep \ - /usr/bin/mkdist \ - /bin/readclock \ - /bin/setup \ - /bin/netconf \ - /usr/bin/binsizes \ - /usr/bin/datasizes \ - /usr/bin/rotate \ - /usr/bin/packit \ - /usr/bin/packman \ - /usr/bin/poweroff \ - /usr/bin/spell \ - /usr/bin/srccrc \ - /usr/bin/svclog \ - /usr/bin/unstack \ - /usr/bin/version \ - /usr/bin/whatis \ - /usr/bin/apropos \ - /usr/bin/whereis \ - -# Commands on the root partition. -root: \ - /bin/M \ - /bin/U \ - /bin/cd \ - /bin/[ \ - /bin/command \ - /bin/echo \ - /bin/expr \ - /bin/false \ - /bin/getopts \ - /bin/read \ - /bin/test \ - /bin/true \ - /bin/umask \ - /bin/wait \ - -clean: - -/usr/bin/DESCRIBE: DESCRIBE.sh - install -m 755 -c -o bin $? $@ - -/usr/bin/M: M.sh - install -m 755 -c -o bin $? $@ - -/usr/bin/U: /usr/bin/M - install -m 755 -l h $? $@ - -/usr/bin/MAKEDEV: MAKEDEV.sh - install -m 755 -c -o bin $? $@ - -/usr/bin/bigmake: bigmake.sh - install -m 755 -c -o bin $? $@ - -/usr/bin/binpackage: binpackage.sh - install -m 755 -c -o bin $? $@ - -/usr/bin/binpackages: binpackages.sh - install -m 755 -c -o bin $? $@ - -/usr/bin/adduser: adduser.sh - install -m 755 -c -o bin $? $@ - -/usr/bin/cd: cd.sh - install -m 755 -c -o bin $? $@ - -/usr/bin/[ /usr/bin/command /usr/bin/echo /usr/bin/expr /usr/bin/false \ -/usr/bin/getopts /usr/bin/read /usr/bin/test /usr/bin/true /usr/bin/umask \ -/usr/bin/wait: /usr/bin/cd - install -m 755 -l h $? $@ - -/usr/bin/easypack: easypack.sh - install -m 755 -c -o bin $? $@ - -/usr/bin/checkhier: checkhier.sh - install -m 755 -c -o bin $? $@ - -/usr/bin/clear: clear.sh - install -m 755 -c -o bin $? $@ - -/usr/bin/clr: /usr/bin/clear - install -m 755 -l h $? $@ - -/usr/bin/makewhatis: makewhatis.sh - install -m 755 -c -o bin $? $@ - -/usr/bin/mkdep: mkdep.sh - install -m 755 -c -o bin $? $@ - -/usr/bin/mkdist: mkdist.sh - install -m 755 -c -o bin $? $@ - -/usr/bin/rotate: rotate.sh - install -m 755 -c -o bin $? $@ - -/bin/readclock: readclock.sh - install -m 755 -c -o bin $? $@ - -/bin/setup: setup.sh - install -m 755 -c -o bin $? $@ - -/bin/netconf: netconf.sh - install -m 755 -c -o bin $? $@ - -/usr/bin/binsizes: binsizes.sh - install -m 755 -c -o bin $? $@ - -/usr/bin/datasizes: datasizes.sh - install -m 755 -c -o bin $? $@ - -/usr/bin/packit: packit.sh - install -m 755 -c -o bin $? $@ - -/usr/bin/packman: packman.sh - install -m 755 -c -o bin $? $@ - -/usr/bin/poweroff: poweroff.sh - install -m 755 -c -o bin $? $@ - -/usr/bin/spell: spell.sh - install -m 755 -c -o bin $? $@ - -/usr/bin/srccrc: srccrc.sh - install -m 755 -c -o bin $? $@ - -/usr/bin/svclog: svclog.sh - install -m 755 -c -o bin $? $@ - -/usr/bin/version: version.sh - install -m 755 -c -o bin $? $@ - -/usr/bin/unstack: unstack.sh - install -m 755 -c -o bin $? $@ - -/usr/bin/whatis: whatis.sh - install -m 755 -c -o bin $? $@ - -/usr/bin/apropos: /usr/bin/whatis - install -m 755 -l h $? $@ - -/usr/bin/whereis: whereis.sh - install -m 755 -c -o bin $? $@ - -/bin/M: /usr/bin/M - install -m 755 -c -o bin $? $@ - -/bin/U: /bin/M - install -m 755 -l h $? $@ - -/bin/cd: /usr/bin/cd - install -m 755 -l h -c $? $@ - -/bin/[ /bin/command /bin/echo /bin/expr /bin/false /bin/getopts \ -/bin/read /bin/test /bin/true /bin/umask /bin/wait: /bin/cd - install -m 755 -l h $? $@ diff --git a/commands/scripts/build b/commands/scripts/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/scripts/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/sdump/Makefile b/commands/sdump/Makefile new file mode 100644 index 000000000..03fec687d --- /dev/null +++ b/commands/sdump/Makefile @@ -0,0 +1,5 @@ +PROG= sdump +CPPFLAGS+= -I${MINIXSRCDIR} -I${MINIXSRCDIR}/servers +MAN= + +.include diff --git a/commands/ibm/sdump.c b/commands/sdump/sdump.c similarity index 96% rename from commands/ibm/sdump.c rename to commands/sdump/sdump.c index 9f9abc2dd..d448fdc9e 100644 --- a/commands/ibm/sdump.c +++ b/commands/sdump/sdump.c @@ -11,12 +11,12 @@ #undef EXTERN #define EXTERN #include -#include "../../servers/pm/const.h" -#include "../../servers/pm/type.h" -#include "../../servers/pm/mproc.h" -#include "../../kernel/const.h" -#include "../../kernel/type.h" -#include "../../kernel/proc.h" +#include "pm/const.h" +#include "pm/type.h" +#include "pm/mproc.h" +#include "kernel/const.h" +#include "kernel/type.h" +#include "kernel/proc.h" #undef printf /* printf was misdefined by the sys headers */ #include diff --git a/commands/sed/Makefile b/commands/sed/Makefile new file mode 100644 index 000000000..17c515e40 --- /dev/null +++ b/commands/sed/Makefile @@ -0,0 +1,5 @@ +PROG= sed +BINDIR= /bin +MAN= + +.include diff --git a/commands/simple/sed.c b/commands/sed/sed.c similarity index 100% rename from commands/simple/sed.c rename to commands/sed/sed.c diff --git a/commands/setup/Makefile b/commands/setup/Makefile new file mode 100644 index 000000000..a78a13ba3 --- /dev/null +++ b/commands/setup/Makefile @@ -0,0 +1,5 @@ +SCRIPTS= setup.sh +BINDIR= /bin +MAN= + +.include diff --git a/commands/scripts/setup.sh b/commands/setup/setup.sh old mode 100755 new mode 100644 similarity index 100% rename from commands/scripts/setup.sh rename to commands/setup/setup.sh diff --git a/commands/sh/Makefile b/commands/sh/Makefile deleted file mode 100644 index 90ecd7031..000000000 --- a/commands/sh/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -# Makefile for sh - -CFLAGS = -O -D_MINIX -D_POSIX_SOURCE -wa -LDFLAGS = -i -CC = exec cc - -OBJ = sh1.o sh2.o sh3.o sh4.o sh5.o sh6.o - -all: sh - -sh: $(OBJ) - cc $(LDFLAGS) -o $@ $(OBJ) - install -S 11kw sh - -install: /usr/bin/msh - -/usr/bin/msh: sh - install -cs -o bin $? $@ - -#/usr/bin/sh: /usr/bin/msh -# install -l h $? $@ -# -#/bin/sh: /usr/bin/msh -# install -l h -cs $? $@ - -$(OBJ): sh.h - -clean: - rm -f sh *.o *.bak core diff --git a/commands/sh/build b/commands/sh/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/sh/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/sh/sh.h b/commands/sh/sh.h deleted file mode 100644 index 8f096bf2e..000000000 --- a/commands/sh/sh.h +++ /dev/null @@ -1,383 +0,0 @@ -#include -#include -#include -#include - -/* Need a way to have void used for ANSI, nothing for K&R. */ -#ifndef _ANSI -#undef _VOID -#define _VOID -#endif - -/* -------- sh.h -------- */ -/* - * shell - */ - -#define LINELIM 4096 -#define NPUSH 8 /* limit to input nesting */ - -#define NOFILE 20 /* Number of open files */ -#define NUFILE 10 /* Number of user-accessible files */ -#define FDBASE 10 /* First file usable by Shell */ - -/* - * values returned by wait - */ -#define WAITSIG(s) ((s)&0177) -#define WAITVAL(s) (((s)>>8)&0377) -#define WAITCORE(s) (((s)&0200)!=0) - -/* - * library and system defintions - */ -#ifdef __STDC__ -typedef void xint; /* base type of jmp_buf, for not broken compilers */ -#else -typedef char * xint; /* base type of jmp_buf, for broken compilers */ -#endif - -/* - * shell components - */ -/* #include "area.h" */ -/* #include "word.h" */ -/* #include "io.h" */ -/* #include "var.h" */ - -#define QUOTE 0200 - -#define NOBLOCK ((struct op *)NULL) -#define NOWORD ((char *)NULL) -#define NOWORDS ((char **)NULL) -#define NOPIPE ((int *)NULL) - -/* - * Description of a command or an operation on commands. - * Might eventually use a union. - */ -struct op { - int type; /* operation type, see below */ - char **words; /* arguments to a command */ - struct ioword **ioact; /* IO actions (eg, < > >>) */ - struct op *left; - struct op *right; - char *str; /* identifier for case and for */ -}; - -#define TCOM 1 /* command */ -#define TPAREN 2 /* (c-list) */ -#define TPIPE 3 /* a | b */ -#define TLIST 4 /* a [&;] b */ -#define TOR 5 /* || */ -#define TAND 6 /* && */ -#define TFOR 7 -#define TDO 8 -#define TCASE 9 -#define TIF 10 -#define TWHILE 11 -#define TUNTIL 12 -#define TELIF 13 -#define TPAT 14 /* pattern in case */ -#define TBRACE 15 /* {c-list} */ -#define TASYNC 16 /* c & */ - -/* - * actions determining the environment of a process - */ -#define BIT(i) (1<<(i)) -#define FEXEC BIT(0) /* execute without forking */ - -/* - * flags to control evaluation of words - */ -#define DOSUB 1 /* interpret $, `, and quotes */ -#define DOBLANK 2 /* perform blank interpretation */ -#define DOGLOB 4 /* interpret [?* */ -#define DOKEY 8 /* move words with `=' to 2nd arg. list */ -#define DOTRIM 16 /* trim resulting string */ - -#define DOALL (DOSUB|DOBLANK|DOGLOB|DOKEY|DOTRIM) - -Extern char **dolv; -Extern int dolc; -Extern int exstat; -Extern char gflg; -Extern int talking; /* interactive (talking-type wireless) */ -Extern int execflg; -Extern int multiline; /* \n changed to ; */ -Extern struct op *outtree; /* result from parser */ - -Extern xint *failpt; -Extern xint *errpt; - -struct brkcon { - jmp_buf brkpt; - struct brkcon *nextlev; -} ; -Extern struct brkcon *brklist; -Extern int isbreak; - -/* - * redirection - */ -struct ioword { - short io_unit; /* unit affected */ - short io_flag; /* action (below) */ - char *io_name; /* file name */ -}; -#define IOREAD 1 /* < */ -#define IOHERE 2 /* << (here file) */ -#define IOWRITE 4 /* > */ -#define IOCAT 8 /* >> */ -#define IOXHERE 16 /* ${}, ` in << */ -#define IODUP 32 /* >&digit */ -#define IOCLOSE 64 /* >&- */ - -#define IODEFAULT (-1) /* token for default IO unit */ - -Extern struct wdblock *wdlist; -Extern struct wdblock *iolist; - -/* - * parsing & execution environment - */ -extern struct env { - char *linep; - struct io *iobase; - struct io *iop; - xint *errpt; - int iofd; - struct env *oenv; -} e; - -/* - * flags: - * -e: quit on error - * -k: look for name=value everywhere on command line - * -n: no execution - * -t: exit after reading and executing one command - * -v: echo as read - * -x: trace - * -u: unset variables net diagnostic - */ -extern char *flag; - -extern char *null; /* null value for variable */ -extern int intr; /* interrupt pending */ - -Extern char *trap[_NSIG+1]; -Extern char ourtrap[_NSIG+1]; -Extern int trapset; /* trap pending */ - -extern int heedint; /* heed interrupt signals */ - -Extern int yynerrs; /* yacc */ - -Extern char line[LINELIM]; -extern char *elinep; - -/* - * other functions - */ -#ifdef __STDC__ -int (*inbuilt(char *s ))(void); -#else -int (*inbuilt())(); -#endif -_PROTOTYPE(char *rexecve , (char *c , char **v , char **envp )); -_PROTOTYPE(char *space , (int n )); -_PROTOTYPE(char *strsave , (char *s , int a )); -_PROTOTYPE(char *evalstr , (char *cp , int f )); -_PROTOTYPE(char *putn , (int n )); -_PROTOTYPE(char *itoa , (unsigned u , int n )); -_PROTOTYPE(char *unquote , (char *as )); -_PROTOTYPE(struct var *lookup , (char *n )); -_PROTOTYPE(int rlookup , (char *n )); -_PROTOTYPE(struct wdblock *glob , (char *cp , struct wdblock *wb )); -_PROTOTYPE(int subgetc , (int ec , int quoted )); -_PROTOTYPE(char **makenv , (void)); -_PROTOTYPE(char **eval , (char **ap , int f )); -_PROTOTYPE(int setstatus , (int s )); -_PROTOTYPE(int waitfor , (int lastpid , int canintr )); - -_PROTOTYPE(void onintr , (int s )); /* SIGINT handler */ - -_PROTOTYPE(int newenv , (int f )); -_PROTOTYPE(void quitenv , (void)); -_PROTOTYPE(void err , (char *s )); -_PROTOTYPE(int anys , (char *s1 , char *s2 )); -_PROTOTYPE(int any , (int c , char *s )); -_PROTOTYPE(void next , (int f )); -_PROTOTYPE(void setdash , (void)); -_PROTOTYPE(void onecommand , (void)); -_PROTOTYPE(void runtrap , (int i )); -_PROTOTYPE(void xfree , (char *s )); -_PROTOTYPE(int letter , (int c )); -_PROTOTYPE(int digit , (int c )); -_PROTOTYPE(int letnum , (int c )); -_PROTOTYPE(int gmatch , (char *s , char *p )); - -/* - * error handling - */ -_PROTOTYPE(void leave , (void)); /* abort shell (or fail in subshell) */ -_PROTOTYPE(void fail , (void)); /* fail but return to process next command */ -_PROTOTYPE(void warn , (char *s )); -_PROTOTYPE(void sig , (int i )); /* default signal handler */ - -/* -------- var.h -------- */ - -struct var { - char *value; - char *name; - struct var *next; - char status; -}; -#define COPYV 1 /* flag to setval, suggesting copy */ -#define RONLY 01 /* variable is read-only */ -#define EXPORT 02 /* variable is to be exported */ -#define GETCELL 04 /* name & value space was got with getcell */ - -Extern struct var *vlist; /* dictionary */ - -Extern struct var *homedir; /* home directory */ -Extern struct var *prompt; /* main prompt */ -Extern struct var *cprompt; /* continuation prompt */ -Extern struct var *path; /* search path for commands */ -Extern struct var *shell; /* shell to interpret command files */ -Extern struct var *ifs; /* field separators */ - -_PROTOTYPE(int yyparse , (void)); -_PROTOTYPE(struct var *lookup , (char *n )); -_PROTOTYPE(void setval , (struct var *vp , char *val )); -_PROTOTYPE(void nameval , (struct var *vp , char *val , char *name )); -_PROTOTYPE(void export , (struct var *vp )); -_PROTOTYPE(void ronly , (struct var *vp )); -_PROTOTYPE(int isassign , (char *s )); -_PROTOTYPE(int checkname , (char *cp )); -_PROTOTYPE(int assign , (char *s , int cf )); -_PROTOTYPE(void putvlist , (int f , int out )); -_PROTOTYPE(int eqname , (char *n1 , char *n2 )); - -_PROTOTYPE(int execute , (struct op *t , int *pin , int *pout , int act )); - -/* -------- io.h -------- */ -/* io buffer */ -struct iobuf { - unsigned id; /* buffer id */ - char buf[512]; /* buffer */ - char *bufp; /* pointer into buffer */ - char *ebufp; /* pointer to end of buffer */ -}; - -/* possible arguments to an IO function */ -struct ioarg { - char *aword; - char **awordlist; - int afile; /* file descriptor */ - unsigned afid; /* buffer id */ - long afpos; /* file position */ - struct iobuf *afbuf; /* buffer for this file */ -}; -Extern struct ioarg ioargstack[NPUSH]; -#define AFID_NOBUF (~0) -#define AFID_ID 0 - -/* an input generator's state */ -struct io { - int (*iofn)(_VOID); - struct ioarg *argp; - int peekc; - char prev; /* previous character read by readc() */ - char nlcount; /* for `'s */ - char xchar; /* for `'s */ - char task; /* reason for pushed IO */ -}; -Extern struct io iostack[NPUSH]; -#define XOTHER 0 /* none of the below */ -#define XDOLL 1 /* expanding ${} */ -#define XGRAVE 2 /* expanding `'s */ -#define XIO 3 /* file IO */ - -/* in substitution */ -#define INSUB() (e.iop->task == XGRAVE || e.iop->task == XDOLL) - -/* - * input generators for IO structure - */ -_PROTOTYPE(int nlchar , (struct ioarg *ap )); -_PROTOTYPE(int strchar , (struct ioarg *ap )); -_PROTOTYPE(int qstrchar , (struct ioarg *ap )); -_PROTOTYPE(int filechar , (struct ioarg *ap )); -_PROTOTYPE(int herechar , (struct ioarg *ap )); -_PROTOTYPE(int linechar , (struct ioarg *ap )); -_PROTOTYPE(int gravechar , (struct ioarg *ap , struct io *iop )); -_PROTOTYPE(int qgravechar , (struct ioarg *ap , struct io *iop )); -_PROTOTYPE(int dolchar , (struct ioarg *ap )); -_PROTOTYPE(int wdchar , (struct ioarg *ap )); -_PROTOTYPE(void scraphere , (void)); -_PROTOTYPE(void freehere , (int area )); -_PROTOTYPE(void gethere , (void)); -_PROTOTYPE(void markhere , (char *s , struct ioword *iop )); -_PROTOTYPE(int herein , (char *hname , int xdoll )); -_PROTOTYPE(int run , (struct ioarg *argp , int (*f)(_VOID))); - -/* - * IO functions - */ -_PROTOTYPE(int eofc , (void)); -_PROTOTYPE(int getc , (int ec )); -_PROTOTYPE(int readc , (void)); -_PROTOTYPE(void unget , (int c )); -_PROTOTYPE(void ioecho , (int c )); -_PROTOTYPE(void prs , (char *s )); -_PROTOTYPE(void putc , (int c )); -_PROTOTYPE(void prn , (unsigned u )); -_PROTOTYPE(void closef , (int i )); -_PROTOTYPE(void closeall , (void)); - -/* - * IO control - */ -_PROTOTYPE(void pushio , (struct ioarg *argp , int (*fn)(_VOID))); -_PROTOTYPE(int remap , (int fd )); -_PROTOTYPE(int openpipe , (int *pv )); -_PROTOTYPE(void closepipe , (int *pv )); -_PROTOTYPE(struct io *setbase , (struct io *ip )); - -extern struct ioarg temparg; /* temporary for PUSHIO */ -#define PUSHIO(what,arg,gen) ((temparg.what = (arg)),pushio(&temparg,(gen))) -#define RUN(what,arg,gen) ((temparg.what = (arg)), run(&temparg,(gen))) - -/* -------- word.h -------- */ -#ifndef WORD_H -#define WORD_H 1 -struct wdblock { - short w_bsize; - short w_nword; - /* bounds are arbitrary */ - char *w_words[1]; -}; - -_PROTOTYPE(struct wdblock *addword , (char *wd , struct wdblock *wb )); -_PROTOTYPE(struct wdblock *newword , (int nw )); -_PROTOTYPE(char **getwords , (struct wdblock *wb )); -#endif - -/* -------- area.h -------- */ - -/* - * storage allocation - */ -_PROTOTYPE(char *getcell , (unsigned nbytes )); -_PROTOTYPE(void garbage , (void)); -_PROTOTYPE(void setarea , (char *cp , int a )); -_PROTOTYPE(int getarea , (char *cp )); -_PROTOTYPE(void freearea , (int a )); -_PROTOTYPE(void freecell , (char *cp )); - -Extern int areanum; /* current allocation area */ - -#define NEW(type) (type *)getcell(sizeof(type)) -#define DELETE(obj) freecell((char *)obj) diff --git a/commands/sh/sh1.c b/commands/sh/sh1.c deleted file mode 100644 index cf45644c2..000000000 --- a/commands/sh/sh1.c +++ /dev/null @@ -1,952 +0,0 @@ -#define Extern extern -#include -#include -#include -#include -#include "sh.h" -/* -------- sh.c -------- */ -/* - * shell - */ - -/* #include "sh.h" */ - -int intr; -int inparse; -char flags['z'-'a'+1]; -char *flag = flags-'a'; -char *elinep = line+sizeof(line)-5; -char *null = ""; -int heedint =1; -struct env e ={line, iostack, iostack-1, - (xint *)NULL, FDBASE, (struct env *)NULL}; - -extern char **environ; /* environment pointer */ - -/* - * default shell, search rules - */ -char shellname[] = "/bin/sh"; -char search[] = ":/bin:/usr/bin"; - -_PROTOTYPE(void (*qflag), (int)) = SIG_IGN; - -_PROTOTYPE(int main, (int argc, char **argv )); -_PROTOTYPE(int newfile, (char *s )); -_PROTOTYPE(static char *findeq, (char *cp )); -_PROTOTYPE(static char *cclass, (char *p, int sub )); -_PROTOTYPE(void initarea, (void)); - -int main(argc, argv) -int argc; -register char **argv; -{ - register int f; - register char *s; - int cflag; - char *name, **ap; - int (*iof)(); - - initarea(); - if ((ap = environ) != NULL) { - while (*ap) - assign(*ap++, !COPYV); - for (ap = environ; *ap;) - export(lookup(*ap++)); - } - closeall(); - areanum = 1; - - shell = lookup("SHELL"); - if (shell->value == null) - setval(shell, shellname); - export(shell); - - homedir = lookup("HOME"); - if (homedir->value == null) - setval(homedir, "/"); - export(homedir); - - setval(lookup("$"), itoa(getpid(), 5)); - - path = lookup("PATH"); - if (path->value == null) - setval(path, search); - export(path); - - ifs = lookup("IFS"); - if (ifs->value == null) - setval(ifs, " \t\n"); - - prompt = lookup("PS1"); - if (prompt->value == null) -#ifndef UNIXSHELL - setval(prompt, "$ "); -#else - setval(prompt, "% "); -#endif - - if (geteuid() == 0) { - setval(prompt, "# "); - prompt->status &= ~EXPORT; - } - cprompt = lookup("PS2"); - if (cprompt->value == null) - setval(cprompt, "> "); - - iof = filechar; - cflag = 0; - name = *argv++; - if (--argc >= 1) { - if(argv[0][0] == '-' && argv[0][1] != '\0') { - for (s = argv[0]+1; *s; s++) - switch (*s) { - case 'c': - prompt->status &= ~EXPORT; - cprompt->status &= ~EXPORT; - setval(prompt, ""); - setval(cprompt, ""); - cflag = 1; - if (--argc > 0) - PUSHIO(aword, *++argv, iof = nlchar); - break; - - case 'q': - qflag = SIG_DFL; - break; - - case 's': - /* standard input */ - break; - - case 't': - prompt->status &= ~EXPORT; - setval(prompt, ""); - iof = linechar; - break; - - case 'i': - talking++; - default: - if (*s>='a' && *s<='z') - flag[*s]++; - } - } else { - argv--; - argc++; - } - if (iof == filechar && --argc > 0) { - setval(prompt, ""); - setval(cprompt, ""); - prompt->status &= ~EXPORT; - cprompt->status &= ~EXPORT; - if (newfile(name = *++argv)) - exit(1); - } - } - setdash(); - if (e.iop < iostack) { - PUSHIO(afile, 0, iof); - if (isatty(0) && isatty(1) && !cflag) - talking++; - } - signal(SIGQUIT, qflag); - if (name && name[0] == '-') { - talking++; - if ((f = open(".profile", 0)) >= 0) - next(remap(f)); - if ((f = open("/etc/profile", 0)) >= 0) - next(remap(f)); - } - if (talking) - signal(SIGTERM, sig); - if (signal(SIGINT, SIG_IGN) != SIG_IGN) - signal(SIGINT, onintr); - dolv = argv; - dolc = argc; - dolv[0] = name; - if (dolc > 1) - for (ap = ++argv; --argc > 0;) - if (assign(*ap = *argv++, !COPYV)) - dolc--; /* keyword */ - else - ap++; - setval(lookup("#"), putn((--dolc < 0) ? (dolc = 0) : dolc)); - - for (;;) { - if (talking && e.iop <= iostack) - prs(prompt->value); - onecommand(); - } -} - -void -setdash() -{ - register char *cp, c; - char m['z'-'a'+1]; - - cp = m; - for (c='a'; c<='z'; c++) - if (flag[c]) - *cp++ = c; - *cp = 0; - setval(lookup("-"), m); -} - -int -newfile(s) -register char *s; -{ - register f; - - if (strcmp(s, "-") != 0) { - f = open(s, 0); - if (f < 0) { - prs(s); - err(": cannot open"); - return(1); - } - } else - f = 0; - next(remap(f)); - return(0); -} - -void -onecommand() -{ - register i; - jmp_buf m1; - - while (e.oenv) - quitenv(); - areanum = 1; - freehere(areanum); - freearea(areanum); - garbage(); - wdlist = 0; - iolist = 0; - e.errpt = 0; - e.linep = line; - yynerrs = 0; - multiline = 0; - inparse = 1; - intr = 0; - execflg = 0; - setjmp(failpt = m1); /* Bruce Evans' fix */ - if (setjmp(failpt = m1) || yyparse() || intr) { - while (e.oenv) - quitenv(); - scraphere(); - if (!talking && intr) - leave(); - inparse = 0; - intr = 0; - return; - } - inparse = 0; - brklist = 0; - intr = 0; - execflg = 0; - if (!flag['n']) - execute(outtree, NOPIPE, NOPIPE, 0); - if (!talking && intr) { - execflg = 0; - leave(); - } - if ((i = trapset) != 0) { - trapset = 0; - runtrap(i); - } -} - -void -fail() -{ - longjmp(failpt, 1); - /* NOTREACHED */ -} - -void -leave() -{ - if (execflg) - fail(); - scraphere(); - freehere(1); - runtrap(0); - exit(exstat); - /* NOTREACHED */ -} - -void -warn(s) -register char *s; -{ - if(*s) { - prs(s); - exstat = -1; - } - prs("\n"); - if (flag['e']) - leave(); -} - -void -err(s) -char *s; -{ - warn(s); - if (flag['n']) - return; - if (!talking) - leave(); - if (e.errpt) - longjmp(e.errpt, 1); - closeall(); - e.iop = e.iobase = iostack; -} - -int -newenv(f) -int f; -{ - register struct env *ep; - - if (f) { - quitenv(); - return(1); - } - ep = (struct env *) space(sizeof(*ep)); - if (ep == NULL) { - while (e.oenv) - quitenv(); - fail(); - } - *ep = e; - e.oenv = ep; - e.errpt = errpt; - return(0); -} - -void -quitenv() -{ - register struct env *ep; - register fd; - - if ((ep = e.oenv) != NULL) { - fd = e.iofd; - e = *ep; - /* should close `'d files */ - DELETE(ep); - while (--fd >= e.iofd) - close(fd); - } -} - -/* - * Is any character from s1 in s2? - */ -int -anys(s1, s2) -register char *s1, *s2; -{ - while (*s1) - if (any(*s1++, s2)) - return(1); - return(0); -} - -/* - * Is character c in s? - */ -int -any(c, s) -register int c; -register char *s; -{ - while (*s) - if (*s++ == c) - return(1); - return(0); -} - -char * -putn(n) -register int n; -{ - return(itoa(n, -1)); -} - -char * -itoa(u, n) -register unsigned u; -int n; -{ - register char *cp; - static char s[20]; - int m; - - m = 0; - if (n < 0 && (int) u < 0) { - m++; - u = -u; - } - cp = s+sizeof(s); - *--cp = 0; - do { - *--cp = u%10 + '0'; - u /= 10; - } while (--n > 0 || u); - if (m) - *--cp = '-'; - return(cp); -} - -void -next(f) -int f; -{ - PUSHIO(afile, f, filechar); -} - -void -onintr(s) -int s; /* ANSI C requires a parameter */ -{ - signal(SIGINT, onintr); - intr = 1; - if (talking) { - if (inparse) { - prs("\n"); - fail(); - } - } - else if (heedint) { - execflg = 0; - leave(); - } -} - -int -letter(c) -register c; -{ - return((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_'); -} - -int -digit(c) -register c; -{ - return(c >= '0' && c <= '9'); -} - -int -letnum(c) -register c; -{ - return(letter(c) || digit(c)); -} - -char * -space(n) -int n; -{ - register char *cp; - - if ((cp = getcell(n)) == 0) - err("out of string space"); - return(cp); -} - -char * -strsave(s, a) -register char *s; -int a; -{ - register char *cp, *xp; - - if ((cp = space(strlen(s)+1)) != NULL) { - setarea((char *)cp, a); - for (xp = cp; (*xp++ = *s++) != '\0';) - ; - return(cp); - } - return(""); -} - -void -xfree(s) -register char *s; -{ - DELETE(s); -} - -/* - * trap handling - */ -void -sig(i) -register int i; -{ - trapset = i; - signal(i, sig); -} - -void runtrap(i) -int i; -{ - char *trapstr; - - if ((trapstr = trap[i]) == NULL) - return; - if (i == 0) - trap[i] = 0; - RUN(aword, trapstr, nlchar); -} - -/* -------- var.c -------- */ -/* #include "sh.h" */ - -/* - * Find the given name in the dictionary - * and return its value. If the name was - * not previously there, enter it now and - * return a null value. - */ -struct var * -lookup(n) -register char *n; -{ - register struct var *vp; - register char *cp; - register int c; - static struct var dummy; - - if (digit(*n)) { - dummy.name = n; - for (c = 0; digit(*n) && c < 1000; n++) - c = c*10 + *n-'0'; - dummy.status = RONLY; - dummy.value = c <= dolc? dolv[c]: null; - return(&dummy); - } - for (vp = vlist; vp; vp = vp->next) - if (eqname(vp->name, n)) - return(vp); - cp = findeq(n); - vp = (struct var *)space(sizeof(*vp)); - if (vp == 0 || (vp->name = space((int)(cp-n)+2)) == 0) { - dummy.name = dummy.value = ""; - return(&dummy); - } - for (cp = vp->name; (*cp = *n++) && *cp != '='; cp++) - ; - if (*cp == 0) - *cp = '='; - *++cp = 0; - setarea((char *)vp, 0); - setarea((char *)vp->name, 0); - vp->value = null; - vp->next = vlist; - vp->status = GETCELL; - vlist = vp; - return(vp); -} - -/* - * give variable at `vp' the value `val'. - */ -void -setval(vp, val) -struct var *vp; -char *val; -{ - nameval(vp, val, (char *)NULL); -} - -/* - * if name is not NULL, it must be - * a prefix of the space `val', - * and end with `='. - * this is all so that exporting - * values is reasonably painless. - */ -void -nameval(vp, val, name) -register struct var *vp; -char *val, *name; -{ - register char *cp, *xp; - char *nv; - int fl; - - if (vp->status & RONLY) { - for (xp = vp->name; *xp && *xp != '=';) - putc(*xp++); - err(" is read-only"); - return; - } - fl = 0; - if (name == NULL) { - xp = space(strlen(vp->name)+strlen(val)+2); - if (xp == 0) - return; - /* make string: name=value */ - setarea((char *)xp, 0); - name = xp; - for (cp = vp->name; (*xp = *cp++) && *xp!='='; xp++) - ; - if (*xp++ == 0) - xp[-1] = '='; - nv = xp; - for (cp = val; (*xp++ = *cp++) != '\0';) - ; - val = nv; - fl = GETCELL; - } - if (vp->status & GETCELL) - xfree(vp->name); /* form new string `name=value' */ - vp->name = name; - vp->value = val; - vp->status |= fl; -} - -void -export(vp) -struct var *vp; -{ - vp->status |= EXPORT; -} - -void -ronly(vp) -struct var *vp; -{ - if (letter(vp->name[0])) /* not an internal symbol ($# etc) */ - vp->status |= RONLY; -} - -int -isassign(s) -register char *s; -{ - if (!letter((int)*s)) - return(0); - for (; *s != '='; s++) - if (*s == 0 || !letnum(*s)) - return(0); - return(1); -} - -int -assign(s, cf) -register char *s; -int cf; -{ - register char *cp; - struct var *vp; - - if (!letter(*s)) - return(0); - for (cp = s; *cp != '='; cp++) - if (*cp == 0 || !letnum(*cp)) - return(0); - vp = lookup(s); - nameval(vp, ++cp, cf == COPYV? (char *)NULL: s); - if (cf != COPYV) - vp->status &= ~GETCELL; - return(1); -} - -int -checkname(cp) -register char *cp; -{ - if (!letter(*cp++)) - return(0); - while (*cp) - if (!letnum(*cp++)) - return(0); - return(1); -} - -void -putvlist(f, out) -register int f, out; -{ - register struct var *vp; - - for (vp = vlist; vp; vp = vp->next) - if (vp->status & f && letter(*vp->name)) { - if (vp->status & EXPORT) - write(out, "export ", 7); - if (vp->status & RONLY) - write(out, "readonly ", 9); - write(out, vp->name, (int)(findeq(vp->name) - vp->name)); - write(out, "\n", 1); - } -} - -int -eqname(n1, n2) -register char *n1, *n2; -{ - for (; *n1 != '=' && *n1 != 0; n1++) - if (*n2++ != *n1) - return(0); - return(*n2 == 0 || *n2 == '='); -} - -static char * -findeq(cp) -register char *cp; -{ - while (*cp != '\0' && *cp != '=') - cp++; - return(cp); -} - -/* -------- gmatch.c -------- */ -/* - * int gmatch(string, pattern) - * char *string, *pattern; - * - * Match a pattern as in sh(1). - */ - -#define CMASK 0377 -#define QUOTE 0200 -#define QMASK (CMASK&~QUOTE) -#define NOT '!' /* might use ^ */ - -int -gmatch(s, p) -register char *s, *p; -{ - register int sc, pc; - - if (s == NULL || p == NULL) - return(0); - while ((pc = *p++ & CMASK) != '\0') { - sc = *s++ & QMASK; - switch (pc) { - case '[': - if ((p = cclass(p, sc)) == NULL) - return(0); - break; - - case '?': - if (sc == 0) - return(0); - break; - - case '*': - s--; - do { - if (*p == '\0' || gmatch(s, p)) - return(1); - } while (*s++ != '\0'); - return(0); - - default: - if (sc != (pc&~QUOTE)) - return(0); - } - } - return(*s == 0); -} - -static char * -cclass(p, sub) -register char *p; -register int sub; -{ - register int c, d, not, found; - - if ((not = *p == NOT) != 0) - p++; - found = not; - do { - if (*p == '\0') - return((char *)NULL); - c = *p & CMASK; - if (p[1] == '-' && p[2] != ']') { - d = p[2] & CMASK; - p++; - } else - d = c; - if (c == sub || (c <= sub && sub <= d)) - found = !not; - } while (*++p != ']'); - return(found? p+1: (char *)NULL); -} - -/* -------- area.c -------- */ -#define REGSIZE sizeof(struct region) -#define GROWBY 256 -#undef SHRINKBY 64 -#define FREE 32767 -#define BUSY 0 -#define ALIGN (sizeof(int)-1) - -/* #include "area.h" */ - -struct region { - struct region *next; - int area; -}; - -/* - * All memory between (char *)areabot and (char *)(areatop+1) is - * exclusively administered by the area management routines. - * It is assumed that sbrk() and brk() manipulate the high end. - */ -static struct region *areabot; /* bottom of area */ -static struct region *areatop; /* top of area */ -static struct region *areanxt; /* starting point of scan */ - -void -initarea() -{ - while ((int)sbrk(0) & ALIGN) - sbrk(1); - areabot = (struct region *)sbrk(REGSIZE); - areabot->next = areabot; - areabot->area = BUSY; - areatop = areabot; - areanxt = areabot; -} - -char * -getcell(nbytes) -unsigned nbytes; -{ - register int nregio; - register struct region *p, *q; - register i; - - if (nbytes == 0) - abort(); /* silly and defeats the algorithm */ - /* - * round upwards and add administration area - */ - nregio = (nbytes+(REGSIZE-1))/REGSIZE + 1; - for (p = areanxt;;) { - if (p->area > areanum) { - /* - * merge free cells - */ - while ((q = p->next)->area > areanum && q != areanxt) - p->next = q->next; - /* - * exit loop if cell big enough - */ - if (q >= p + nregio) - goto found; - } - p = p->next; - if (p == areanxt) - break; - } - i = nregio >= GROWBY ? nregio : GROWBY; - p = (struct region *)sbrk(i * REGSIZE); - if (p == (struct region *)-1) - return((char *)NULL); - p--; - if (p != areatop) - abort(); /* allocated areas are contiguous */ - q = p + i; - p->next = q; - p->area = FREE; - q->next = areabot; - q->area = BUSY; - areatop = q; -found: - /* - * we found a FREE area big enough, pointed to by 'p', and up to 'q' - */ - areanxt = p + nregio; - if (areanxt < q) { - /* - * split into requested area and rest - */ - if (areanxt+1 > q) - abort(); /* insufficient space left for admin */ - areanxt->next = q; - areanxt->area = FREE; - p->next = areanxt; - } - p->area = areanum; - return((char *)(p+1)); -} - -void -freecell(cp) -char *cp; -{ - register struct region *p; - - if ((p = (struct region *)cp) != NULL) { - p--; - if (p < areanxt) - areanxt = p; - p->area = FREE; - } -} - -void -freearea(a) -register int a; -{ - register struct region *p, *top; - - top = areatop; - for (p = areabot; p != top; p = p->next) - if (p->area >= a) - p->area = FREE; -} - -void -setarea(cp,a) -char *cp; -int a; -{ - register struct region *p; - - if ((p = (struct region *)cp) != NULL) - (p-1)->area = a; -} - -int -getarea(cp) -char *cp; -{ - return ((struct region*)cp-1)->area; -} - -void -garbage() -{ - register struct region *p, *q, *top; - - top = areatop; - for (p = areabot; p != top; p = p->next) { - if (p->area > areanum) { - while ((q = p->next)->area > areanum) - p->next = q->next; - areanxt = p; - } - } -#ifdef SHRINKBY - if (areatop >= q + SHRINKBY && q->area > areanum) { - brk((char *)(q+1)); - q->next = areabot; - q->area = BUSY; - areatop = q; - } -#endif -} diff --git a/commands/sh/sh2.c b/commands/sh/sh2.c deleted file mode 100644 index 2a9f80f72..000000000 --- a/commands/sh/sh2.c +++ /dev/null @@ -1,800 +0,0 @@ -#define Extern extern -#include -#include -#include -#include -#include "sh.h" - -/* -------- csyn.c -------- */ -/* - * shell: syntax (C version) - */ - -typedef union { - char *cp; - char **wp; - int i; - struct op *o; -} YYSTYPE; -#define WORD 256 -#define LOGAND 257 -#define LOGOR 258 -#define BREAK 259 -#define IF 260 -#define THEN 261 -#define ELSE 262 -#define ELIF 263 -#define FI 264 -#define CASE 265 -#define ESAC 266 -#define FOR 267 -#define WHILE 268 -#define UNTIL 269 -#define DO 270 -#define DONE 271 -#define IN 272 -#define YYERRCODE 300 - -/* flags to yylex */ -#define CONTIN 01 /* skip new lines to complete command */ - -/* #include "sh.h" */ -#define SYNTAXERR zzerr() -static int startl; -static int peeksym; -static int nlseen; -static int iounit = IODEFAULT; - -static YYSTYPE yylval; - -_PROTOTYPE(static struct op *pipeline, (int cf )); -_PROTOTYPE(static struct op *andor, (void)); -_PROTOTYPE(static struct op *c_list, (void)); -_PROTOTYPE(static int synio, (int cf )); -_PROTOTYPE(static void musthave, (int c, int cf )); -_PROTOTYPE(static struct op *simple, (void)); -_PROTOTYPE(static struct op *nested, (int type, int mark )); -_PROTOTYPE(static struct op *command, (int cf )); -_PROTOTYPE(static struct op *dogroup, (int onlydone )); -_PROTOTYPE(static struct op *thenpart, (void)); -_PROTOTYPE(static struct op *elsepart, (void)); -_PROTOTYPE(static struct op *caselist, (void)); -_PROTOTYPE(static struct op *casepart, (void)); -_PROTOTYPE(static char **pattern, (void)); -_PROTOTYPE(static char **wordlist, (void)); -_PROTOTYPE(static struct op *list, (struct op *t1, struct op *t2 )); -_PROTOTYPE(static struct op *block, (int type, struct op *t1, struct op *t2, char **wp )); -_PROTOTYPE(static struct op *newtp, (void)); -_PROTOTYPE(static struct op *namelist, (struct op *t )); -_PROTOTYPE(static char **copyw, (void)); -_PROTOTYPE(static void word, (char *cp )); -_PROTOTYPE(static struct ioword **copyio, (void)); -_PROTOTYPE(static struct ioword *io, (int u, int f, char *cp )); -_PROTOTYPE(static void zzerr, (void)); -_PROTOTYPE(void yyerror, (char *s )); -_PROTOTYPE(static int yylex, (int cf )); -_PROTOTYPE(int collect, (int c, int c1 )); -_PROTOTYPE(int dual, (int c )); -_PROTOTYPE(static void diag, (int ec )); -_PROTOTYPE(static char *tree, (unsigned size )); -_PROTOTYPE(void printf, (char *s )); - -int -yyparse() -{ - startl = 1; - peeksym = 0; - yynerrs = 0; - outtree = c_list(); - musthave('\n', 0); - return(yynerrs!=0); -} - -static struct op * -pipeline(cf) -int cf; -{ - register struct op *t, *p; - register int c; - - t = command(cf); - if (t != NULL) { - while ((c = yylex(0)) == '|') { - if ((p = command(CONTIN)) == NULL) - SYNTAXERR; - if (t->type != TPAREN && t->type != TCOM) { - /* shell statement */ - t = block(TPAREN, t, NOBLOCK, NOWORDS); - } - t = block(TPIPE, t, p, NOWORDS); - } - peeksym = c; - } - return(t); -} - -static struct op * -andor() -{ - register struct op *t, *p; - register int c; - - t = pipeline(0); - if (t != NULL) { - while ((c = yylex(0)) == LOGAND || c == LOGOR) { - if ((p = pipeline(CONTIN)) == NULL) - SYNTAXERR; - t = block(c == LOGAND? TAND: TOR, t, p, NOWORDS); - } - peeksym = c; - } - return(t); -} - -static struct op * -c_list() -{ - register struct op *t, *p; - register int c; - - t = andor(); - if (t != NULL) { - if((peeksym = yylex(0)) == '&') - t = block(TASYNC, t, NOBLOCK, NOWORDS); - while ((c = yylex(0)) == ';' || c == '&' || (multiline && c == '\n')) { - if ((p = andor()) == NULL) - return(t); - if((peeksym = yylex(0)) == '&') - p = block(TASYNC, p, NOBLOCK, NOWORDS); - t = list(t, p); - } - peeksym = c; - } - return(t); -} - - -static int -synio(cf) -int cf; -{ - register struct ioword *iop; - register int i; - register int c; - - if ((c = yylex(cf)) != '<' && c != '>') { - peeksym = c; - return(0); - } - i = yylval.i; - musthave(WORD, 0); - iop = io(iounit, i, yylval.cp); - iounit = IODEFAULT; - if (i & IOHERE) - markhere(yylval.cp, iop); - return(1); -} - -static void -musthave(c, cf) -int c, cf; -{ - if ((peeksym = yylex(cf)) != c) - SYNTAXERR; - peeksym = 0; -} - -static struct op * -simple() -{ - register struct op *t; - - t = NULL; - for (;;) { - switch (peeksym = yylex(0)) { - case '<': - case '>': - (void) synio(0); - break; - - case WORD: - if (t == NULL) { - t = newtp(); - t->type = TCOM; - } - peeksym = 0; - word(yylval.cp); - break; - - default: - return(t); - } - } -} - -static struct op * -nested(type, mark) -int type, mark; -{ - register struct op *t; - - multiline++; - t = c_list(); - musthave(mark, 0); - multiline--; - return(block(type, t, NOBLOCK, NOWORDS)); -} - -static struct op * -command(cf) -int cf; -{ - register struct op *t; - struct wdblock *iosave; - register int c; - - iosave = iolist; - iolist = NULL; - if (multiline) - cf |= CONTIN; - while (synio(cf)) - cf = 0; - switch (c = yylex(cf)) { - default: - peeksym = c; - if ((t = simple()) == NULL) { - if (iolist == NULL) - return((struct op *)NULL); - t = newtp(); - t->type = TCOM; - } - break; - - case '(': - t = nested(TPAREN, ')'); - break; - - case '{': - t = nested(TBRACE, '}'); - break; - - case FOR: - t = newtp(); - t->type = TFOR; - musthave(WORD, 0); - startl = 1; - t->str = yylval.cp; - multiline++; - t->words = wordlist(); - if ((c = yylex(0)) != '\n' && c != ';') - peeksym = c; - t->left = dogroup(0); - multiline--; - break; - - case WHILE: - case UNTIL: - multiline++; - t = newtp(); - t->type = c == WHILE? TWHILE: TUNTIL; - t->left = c_list(); - t->right = dogroup(1); - t->words = NULL; - multiline--; - break; - - case CASE: - t = newtp(); - t->type = TCASE; - musthave(WORD, 0); - t->str = yylval.cp; - startl++; - multiline++; - musthave(IN, CONTIN); - startl++; - t->left = caselist(); - musthave(ESAC, 0); - multiline--; - break; - - case IF: - multiline++; - t = newtp(); - t->type = TIF; - t->left = c_list(); - t->right = thenpart(); - musthave(FI, 0); - multiline--; - break; - } - while (synio(0)) - ; - t = namelist(t); - iolist = iosave; - return(t); -} - -static struct op * -dogroup(onlydone) -int onlydone; -{ - register int c; - register struct op *list; - - c = yylex(CONTIN); - if (c == DONE && onlydone) - return((struct op *)NULL); - if (c != DO) - SYNTAXERR; - list = c_list(); - musthave(DONE, 0); - return(list); -} - -static struct op * -thenpart() -{ - register int c; - register struct op *t; - - if ((c = yylex(0)) != THEN) { - peeksym = c; - return((struct op *)NULL); - } - t = newtp(); - t->type = 0; - t->left = c_list(); - if (t->left == NULL) - SYNTAXERR; - t->right = elsepart(); - return(t); -} - -static struct op * -elsepart() -{ - register int c; - register struct op *t; - - switch (c = yylex(0)) { - case ELSE: - if ((t = c_list()) == NULL) - SYNTAXERR; - return(t); - - case ELIF: - t = newtp(); - t->type = TELIF; - t->left = c_list(); - t->right = thenpart(); - return(t); - - default: - peeksym = c; - return((struct op *)NULL); - } -} - -static struct op * -caselist() -{ - register struct op *t; - - t = NULL; - while ((peeksym = yylex(CONTIN)) != ESAC) - t = list(t, casepart()); - return(t); -} - -static struct op * -casepart() -{ - register struct op *t; - - t = newtp(); - t->type = TPAT; - t->words = pattern(); - musthave(')', 0); - t->left = c_list(); - if ((peeksym = yylex(CONTIN)) != ESAC) - musthave(BREAK, CONTIN); - return(t); -} - -static char ** -pattern() -{ - register int c, cf; - - cf = CONTIN; - do { - musthave(WORD, cf); - word(yylval.cp); - cf = 0; - } while ((c = yylex(0)) == '|'); - peeksym = c; - word(NOWORD); - return(copyw()); -} - -static char ** -wordlist() -{ - register int c; - - if ((c = yylex(0)) != IN) { - peeksym = c; - return((char **)NULL); - } - startl = 0; - while ((c = yylex(0)) == WORD) - word(yylval.cp); - word(NOWORD); - peeksym = c; - return(copyw()); -} - -/* - * supporting functions - */ -static struct op * -list(t1, t2) -register struct op *t1, *t2; -{ - if (t1 == NULL) - return(t2); - if (t2 == NULL) - return(t1); - return(block(TLIST, t1, t2, NOWORDS)); -} - -static struct op * -block(type, t1, t2, wp) -int type; -struct op *t1, *t2; -char **wp; -{ - register struct op *t; - - t = newtp(); - t->type = type; - t->left = t1; - t->right = t2; - t->words = wp; - return(t); -} - -struct res { - char *r_name; - int r_val; -} restab[] = { - "for", FOR, - "case", CASE, - "esac", ESAC, - "while", WHILE, - "do", DO, - "done", DONE, - "if", IF, - "in", IN, - "then", THEN, - "else", ELSE, - "elif", ELIF, - "until", UNTIL, - "fi", FI, - - ";;", BREAK, - "||", LOGOR, - "&&", LOGAND, - "{", '{', - "}", '}', - - 0, -}; - -int -rlookup(n) -register char *n; -{ - register struct res *rp; - - for (rp = restab; rp->r_name; rp++) - if (strcmp(rp->r_name, n) == 0) - return(rp->r_val); - return(0); -} - -static struct op * -newtp() -{ - register struct op *t; - - t = (struct op *)tree(sizeof(*t)); - t->type = 0; - t->words = NULL; - t->ioact = NULL; - t->left = NULL; - t->right = NULL; - t->str = NULL; - return(t); -} - -static struct op * -namelist(t) -register struct op *t; -{ - if (iolist) { - iolist = addword((char *)NULL, iolist); - t->ioact = copyio(); - } else - t->ioact = NULL; - if (t->type != TCOM) { - if (t->type != TPAREN && t->ioact != NULL) { - t = block(TPAREN, t, NOBLOCK, NOWORDS); - t->ioact = t->left->ioact; - t->left->ioact = NULL; - } - return(t); - } - word(NOWORD); - t->words = copyw(); - return(t); -} - -static char ** -copyw() -{ - register char **wd; - - wd = getwords(wdlist); - wdlist = 0; - return(wd); -} - -static void -word(cp) -char *cp; -{ - wdlist = addword(cp, wdlist); -} - -static struct ioword ** -copyio() -{ - register struct ioword **iop; - - iop = (struct ioword **) getwords(iolist); - iolist = 0; - return(iop); -} - -static struct ioword * -io(u, f, cp) -int u; -int f; -char *cp; -{ - register struct ioword *iop; - - iop = (struct ioword *) tree(sizeof(*iop)); - iop->io_unit = u; - iop->io_flag = f; - iop->io_name = cp; - iolist = addword((char *)iop, iolist); - return(iop); -} - -static void -zzerr() -{ - yyerror("syntax error"); -} - -void -yyerror(s) -char *s; -{ - yynerrs++; - if (talking && e.iop <= iostack) { - multiline = 0; - while (eofc() == 0 && yylex(0) != '\n') - ; - } - err(s); - fail(); -} - -static int -yylex(cf) -int cf; -{ - register int c, c1; - int atstart; - - if ((c = peeksym) > 0) { - peeksym = 0; - if (c == '\n') - startl = 1; - return(c); - } - nlseen = 0; - e.linep = line; - atstart = startl; - startl = 0; - yylval.i = 0; - -loop: - while ((c = getc(0)) == ' ' || c == '\t') - ; - switch (c) { - default: - if (any(c, "0123456789")) { - unget(c1 = getc(0)); - if (c1 == '<' || c1 == '>') { - iounit = c - '0'; - goto loop; - } - *e.linep++ = c; - c = c1; - } - break; - - case '#': - while ((c = getc(0)) != 0 && c != '\n') - ; - unget(c); - goto loop; - - case 0: - return(c); - - case '$': - *e.linep++ = c; - if ((c = getc(0)) == '{') { - if ((c = collect(c, '}')) != '\0') - return(c); - goto pack; - } - break; - - case '`': - case '\'': - case '"': - if ((c = collect(c, c)) != '\0') - return(c); - goto pack; - - case '|': - case '&': - case ';': - if ((c1 = dual(c)) != '\0') { - startl = 1; - return(c1); - } - startl = 1; - return(c); - case '^': - startl = 1; - return('|'); - case '>': - case '<': - diag(c); - return(c); - - case '\n': - nlseen++; - gethere(); - startl = 1; - if (multiline || cf & CONTIN) { - if (talking && e.iop <= iostack) - prs(cprompt->value); - if (cf & CONTIN) - goto loop; - } - return(c); - - case '(': - case ')': - startl = 1; - return(c); - } - - unget(c); - -pack: - while ((c = getc(0)) != 0 && !any(c, "`$ '\"\t;&<>()|^\n")) - if (e.linep >= elinep) - err("word too long"); - else - *e.linep++ = c; - unget(c); - if(any(c, "\"'`$")) - goto loop; - *e.linep++ = '\0'; - if (atstart && (c = rlookup(line))!=0) { - startl = 1; - return(c); - } - yylval.cp = strsave(line, areanum); - return(WORD); -} - -int -collect(c, c1) -register c, c1; -{ - char s[2]; - - *e.linep++ = c; - while ((c = getc(c1)) != c1) { - if (c == 0) { - unget(c); - s[0] = c1; - s[1] = 0; - prs("no closing "); yyerror(s); - return(YYERRCODE); - } - if (talking && c == '\n' && e.iop <= iostack) - prs(cprompt->value); - *e.linep++ = c; - } - *e.linep++ = c; - return(0); -} - -int -dual(c) -register c; -{ - char s[3]; - register char *cp = s; - - *cp++ = c; - *cp++ = getc(0); - *cp = 0; - if ((c = rlookup(s)) == 0) - unget(*--cp); - return(c); -} - -static void -diag(ec) -register int ec; -{ - register int c; - - c = getc(0); - if (c == '>' || c == '<') { - if (c != ec) - zzerr(); - yylval.i = ec == '>'? IOWRITE|IOCAT: IOHERE; - c = getc(0); - } else - yylval.i = ec == '>'? IOWRITE: IOREAD; - if (c != '&' || yylval.i == IOHERE) - unget(c); - else - yylval.i |= IODUP; -} - -static char * -tree(size) -unsigned size; -{ - register char *t; - - if ((t = getcell(size)) == NULL) { - prs("command line too complicated\n"); - fail(); - /* NOTREACHED */ - } - return(t); -} - -/* VARARGS1 */ -/* ARGSUSED */ -void -printf(s) /* yyparse calls it */ -char *s; -{ -} - diff --git a/commands/sh/sh3.c b/commands/sh/sh3.c deleted file mode 100644 index cdba82b58..000000000 --- a/commands/sh/sh3.c +++ /dev/null @@ -1,1147 +0,0 @@ -#define Extern extern -#include -#include -#include -#include -#include -#include -#include -#include -#include -#undef NULL -#include "sh.h" - -/* -------- exec.c -------- */ -/* #include "sh.h" */ - -/* - * execute tree - */ - -static char *signame[] = { - "Signal 0", - "Hangup", - (char *)NULL, /* interrupt */ - "Quit", - "Illegal instruction", - "Trace/BPT trap", - "Abort", - "EMT trap", - "Floating exception", - "Killed", - "Bus error", - "Memory fault", - "Bad system call", - (char *)NULL, /* broken pipe */ - "Alarm clock", - "Terminated", -}; -#define NSIGNAL (sizeof(signame)/sizeof(signame[0])) - - -_PROTOTYPE(static int forkexec, (struct op *t, int *pin, int *pout, int act, char **wp, int *pforked )); -_PROTOTYPE(static int parent, (void)); -_PROTOTYPE(int iosetup, (struct ioword *iop, int pipein, int pipeout )); -_PROTOTYPE(static void echo, (char **wp )); -_PROTOTYPE(static struct op **find1case, (struct op *t, char *w )); -_PROTOTYPE(static struct op *findcase, (struct op *t, char *w )); -_PROTOTYPE(static void brkset, (struct brkcon *bc )); -_PROTOTYPE(int dolabel, (void)); -_PROTOTYPE(int dochdir, (struct op *t )); -_PROTOTYPE(int doshift, (struct op *t )); -_PROTOTYPE(int dologin, (struct op *t )); -_PROTOTYPE(int doumask, (struct op *t )); -_PROTOTYPE(int doexec, (struct op *t )); -_PROTOTYPE(int dodot, (struct op *t )); -_PROTOTYPE(int dowait, (struct op *t )); -_PROTOTYPE(int doread, (struct op *t )); -_PROTOTYPE(int doeval, (struct op *t )); -_PROTOTYPE(int dotrap, (struct op *t )); -_PROTOTYPE(int getsig, (char *s )); -_PROTOTYPE(void setsig, (int n, void (*f)())); -_PROTOTYPE(int getn, (char *as )); -_PROTOTYPE(int dobreak, (struct op *t )); -_PROTOTYPE(int docontinue, (struct op *t )); -_PROTOTYPE(static int brkcontin, (char *cp, int val )); -_PROTOTYPE(int doexit, (struct op *t )); -_PROTOTYPE(int doexport, (struct op *t )); -_PROTOTYPE(int doreadonly, (struct op *t )); -_PROTOTYPE(static void rdexp, (char **wp, void (*f)(), int key)); -_PROTOTYPE(static void badid, (char *s )); -_PROTOTYPE(int doset, (struct op *t )); -_PROTOTYPE(void varput, (char *s, int out )); -_PROTOTYPE(int dotimes, (void)); - -int -execute(t, pin, pout, act) -register struct op *t; -int *pin, *pout; -int act; -{ - register struct op *t1; - int i, pv[2], rv, child, a; - char *cp, **wp, **wp2; - struct var *vp; - struct brkcon bc; - - if (t == NULL) - return(0); - rv = 0; - a = areanum++; - wp = (wp2 = t->words) != NULL - ? eval(wp2, t->type == TCOM ? DOALL : DOALL & ~DOKEY) - : NULL; - - switch(t->type) { - case TPAREN: - case TCOM: - rv = forkexec(t, pin, pout, act, wp, &child); - if (child) { - exstat = rv; - leave(); - } - break; - - case TPIPE: - if ((rv = openpipe(pv)) < 0) - break; - pv[0] = remap(pv[0]); - pv[1] = remap(pv[1]); - (void) execute(t->left, pin, pv, 0); - rv = execute(t->right, pv, pout, 0); - break; - - case TLIST: - (void) execute(t->left, pin, pout, 0); - rv = execute(t->right, pin, pout, 0); - break; - - case TASYNC: - i = parent(); - if (i != 0) { - if (i != -1) { - setval(lookup("!"), putn(i)); - if (pin != NULL) - closepipe(pin); - if (talking) { - prs(putn(i)); - prs("\n"); - } - } else - rv = -1; - setstatus(rv); - } else { - signal(SIGINT, SIG_IGN); - signal(SIGQUIT, SIG_IGN); - if (talking) - signal(SIGTERM, SIG_DFL); - talking = 0; - if (pin == NULL) { - close(0); - open("/dev/null", 0); - } - exit(execute(t->left, pin, pout, FEXEC)); - } - break; - - case TOR: - case TAND: - rv = execute(t->left, pin, pout, 0); - if ((t1 = t->right)!=NULL && (rv == 0) == (t->type == TAND)) - rv = execute(t1, pin, pout, 0); - break; - - case TFOR: - if (wp == NULL) { - wp = dolv+1; - if ((i = dolc) < 0) - i = 0; - } else { - i = -1; - while (*wp++ != NULL) - ; - } - vp = lookup(t->str); - while (setjmp(bc.brkpt)) - if (isbreak) - goto broken; - brkset(&bc); - for (t1 = t->left; i-- && *wp != NULL;) { - setval(vp, *wp++); - rv = execute(t1, pin, pout, 0); - } - brklist = brklist->nextlev; - break; - - case TWHILE: - case TUNTIL: - while (setjmp(bc.brkpt)) - if (isbreak) - goto broken; - brkset(&bc); - t1 = t->left; - while ((execute(t1, pin, pout, 0) == 0) == (t->type == TWHILE)) - rv = execute(t->right, pin, pout, 0); - brklist = brklist->nextlev; - break; - - case TIF: - case TELIF: - if (t->right != NULL) { - rv = !execute(t->left, pin, pout, 0) ? - execute(t->right->left, pin, pout, 0): - execute(t->right->right, pin, pout, 0); - } - break; - - case TCASE: - if ((cp = evalstr(t->str, DOSUB|DOTRIM)) == 0) - cp = ""; - if ((t1 = findcase(t->left, cp)) != NULL) - rv = execute(t1, pin, pout, 0); - break; - - case TBRACE: -/* - if (iopp = t->ioact) - while (*iopp) - if (iosetup(*iopp++, pin!=NULL, pout!=NULL)) { - rv = -1; - break; - } -*/ - if (rv >= 0 && (t1 = t->left)) - rv = execute(t1, pin, pout, 0); - break; - } - -broken: - t->words = wp2; - isbreak = 0; - freehere(areanum); - freearea(areanum); - areanum = a; - if (talking && intr) { - closeall(); - fail(); - } - if ((i = trapset) != 0) { - trapset = 0; - runtrap(i); - } - return(rv); -} - -static int -forkexec(t, pin, pout, act, wp, pforked) -register struct op *t; -int *pin, *pout; -int act; -char **wp; -int *pforked; -{ - int i, rv, (*shcom)(); - register int f; - char *cp; - struct ioword **iopp; - int resetsig; - char **owp; - - owp = wp; - resetsig = 0; - *pforked = 0; - shcom = NULL; - rv = -1; /* system-detected error */ - if (t->type == TCOM) { - while ((cp = *wp++) != NULL) - ; - cp = *wp; - - /* strip all initial assignments */ - /* not correct wrt PATH=yyy command etc */ - if (flag['x']) - echo (cp ? wp: owp); - if (cp == NULL && t->ioact == NULL) { - while ((cp = *owp++) != NULL && assign(cp, COPYV)) - ; - return(setstatus(0)); - } - else if (cp != NULL) - shcom = inbuilt(cp); - } - t->words = wp; - f = act; - if (shcom == NULL && (f & FEXEC) == 0) { - i = parent(); - if (i != 0) { - if (i == -1) - return(rv); - if (pin != NULL) - closepipe(pin); - return(pout==NULL? setstatus(waitfor(i,0)): 0); - } - if (talking) { - signal(SIGINT, SIG_IGN); - signal(SIGQUIT, SIG_IGN); - resetsig = 1; - } - talking = 0; - intr = 0; - (*pforked)++; - brklist = 0; - execflg = 0; - } - if (owp != NULL) - while ((cp = *owp++) != NULL && assign(cp, COPYV)) - if (shcom == NULL) - export(lookup(cp)); -#ifdef COMPIPE - if ((pin != NULL || pout != NULL) && shcom != NULL && shcom != doexec) { - err("piping to/from shell builtins not yet done"); - return(-1); - } -#endif - if (pin != NULL) { - dup2(pin[0], 0); - closepipe(pin); - } - if (pout != NULL) { - dup2(pout[1], 1); - closepipe(pout); - } - if ((iopp = t->ioact) != NULL) { - if (shcom != NULL && shcom != doexec) { - prs(cp); - err(": cannot redirect shell command"); - return(-1); - } - while (*iopp) - if (iosetup(*iopp++, pin!=NULL, pout!=NULL)) - return(rv); - } - if (shcom) - return(setstatus((*shcom)(t))); - /* should use FIOCEXCL */ - for (i=FDBASE; itype == TPAREN) - exit(execute(t->left, NOPIPE, NOPIPE, FEXEC)); - if (wp[0] == NULL) - exit(0); - cp = rexecve(wp[0], wp, makenv()); - prs(wp[0]); prs(": "); warn(cp); - if (!execflg) - trap[0] = NULL; - leave(); - /* NOTREACHED */ -} - -/* - * common actions when creating a new child - */ -static int -parent() -{ - register int i; - - i = fork(); - if (i != 0) { - if (i == -1) - warn("try again"); - } - return(i); -} - -/* - * 0< 1> are ignored as required - * within pipelines. - */ -int -iosetup(iop, pipein, pipeout) -register struct ioword *iop; -int pipein, pipeout; -{ - register u; - char *cp, *msg; - - if (iop->io_unit == IODEFAULT) /* take default */ - iop->io_unit = iop->io_flag&(IOREAD|IOHERE)? 0: 1; - if (pipein && iop->io_unit == 0) - return(0); - if (pipeout && iop->io_unit == 1) - return(0); - msg = iop->io_flag&(IOREAD|IOHERE)? "open": "create"; - if ((iop->io_flag & IOHERE) == 0) { - cp = iop->io_name; - if ((cp = evalstr(cp, DOSUB|DOTRIM)) == NULL) - return(1); - } - if (iop->io_flag & IODUP) { - if (cp[1] || (!digit(*cp) && *cp != '-')) { - prs(cp); - err(": illegal >& argument"); - return(1); - } - if (*cp == '-') - iop->io_flag = IOCLOSE; - iop->io_flag &= ~(IOREAD|IOWRITE); - } - switch (iop->io_flag) { - case IOREAD: - u = open(cp, 0); - break; - - case IOHERE: - case IOHERE|IOXHERE: - u = herein(iop->io_name, iop->io_flag&IOXHERE); - cp = "here file "; - break; - - case IOWRITE|IOCAT: - if ((u = open(cp, 1)) >= 0) { - lseek(u, (long)0, 2); - break; - } - case IOWRITE: - u = creat(cp, 0666); - break; - - case IODUP: - u = dup2(*cp-'0', iop->io_unit); - break; - - case IOCLOSE: - close(iop->io_unit); - return(0); - } - if (u < 0) { - int e=errno; - prs(cp); - if (iop->io_flag&IOHERE) prs(iop->io_name); - prs(": cannot "); - prs(msg); - prs(" ("); - prs(strerror(e)); - warn(")"); - return(1); - } else { - if (u != iop->io_unit) { - dup2(u, iop->io_unit); - close(u); - } - } - return(0); -} - -static void -echo(wp) -register char **wp; -{ - register i; - - prs("+"); - for (i=0; wp[i]; i++) { - if (i) - prs(" "); - prs(wp[i]); - } - prs("\n"); -} - -static struct op ** -find1case(t, w) -struct op *t; -char *w; -{ - register struct op *t1; - struct op **tp; - register char **wp, *cp; - - if (t == NULL) - return((struct op **)NULL); - if (t->type == TLIST) { - if ((tp = find1case(t->left, w)) != NULL) - return(tp); - t1 = t->right; /* TPAT */ - } else - t1 = t; - for (wp = t1->words; *wp;) - if ((cp = evalstr(*wp++, DOSUB)) && gmatch(w, cp)) - return(&t1->left); - return((struct op **)NULL); -} - -static struct op * -findcase(t, w) -struct op *t; -char *w; -{ - register struct op **tp; - - return((tp = find1case(t, w)) != NULL? *tp: (struct op *)NULL); -} - -/* - * Enter a new loop level (marked for break/continue). - */ -static void -brkset(bc) -struct brkcon *bc; -{ - bc->nextlev = brklist; - brklist = bc; -} - -/* - * Wait for the last process created. - * Print a message for each process found - * that was killed by a signal. - * Ignore interrupt signals while waiting - * unless `canintr' is true. - */ -int -waitfor(lastpid, canintr) -register int lastpid; -int canintr; -{ - register int pid, rv; - int s; - int oheedint = heedint; - - heedint = 0; - rv = 0; - do { - pid = wait(&s); - if (pid == -1) { - if (errno != EINTR || canintr) - break; - } else { - if ((rv = WAITSIG(s)) != 0) { - if (rv < NSIGNAL) { - if (signame[rv] != NULL) { - if (pid != lastpid) { - prn(pid); - prs(": "); - } - prs(signame[rv]); - } - } else { - if (pid != lastpid) { - prn(pid); - prs(": "); - } - prs("Signal "); prn(rv); prs(" "); - } - if (WAITCORE(s)) - prs(" - core dumped"); - if (rv >= NSIGNAL || signame[rv]) - prs("\n"); - rv = -1; - } else - rv = WAITVAL(s); - } - } while (pid != lastpid); - heedint = oheedint; - if (intr) - if (talking) { - if (canintr) - intr = 0; - } else { - if (exstat == 0) exstat = rv; - onintr(0); - } - return(rv); -} - -int -setstatus(s) -register int s; -{ - exstat = s; - setval(lookup("?"), putn(s)); - return(s); -} - -/* - * PATH-searching interface to execve. - * If getenv("PATH") were kept up-to-date, - * execvp might be used. - */ -char * -rexecve(c, v, envp) -char *c, **v, **envp; -{ - register int i; - register char *sp, *tp; - int eacces = 0, asis = 0; - - sp = any('/', c)? "": path->value; - asis = *sp == '\0'; - while (asis || *sp != '\0') { - asis = 0; - tp = e.linep; - for (; *sp != '\0'; tp++) - if ((*tp = *sp++) == ':') { - asis = *sp == '\0'; - break; - } - if (tp != e.linep) - *tp++ = '/'; - for (i = 0; (*tp++ = c[i++]) != '\0';) - ; - execve(e.linep, v, envp); - switch (errno) { - case ENOEXEC: - *v = e.linep; - tp = *--v; - *v = e.linep; - execve("/bin/sh", v, envp); - *v = tp; - return("no Shell"); - - case ENOMEM: - return("program too big"); - - case E2BIG: - return("argument list too long"); - - case EACCES: - eacces++; - break; - } - } - return(errno==ENOENT ? "not found" : "cannot execute"); -} - -/* - * Run the command produced by generator `f' - * applied to stream `arg'. - */ -int -run(argp, f) -struct ioarg *argp; -int (*f)(); -{ - struct op *otree; - struct wdblock *swdlist; - struct wdblock *siolist; - jmp_buf ev, rt; - xint *ofail; - int rv; - - areanum++; - swdlist = wdlist; - siolist = iolist; - otree = outtree; - ofail = failpt; - rv = -1; - if (newenv(setjmp(errpt = ev)) == 0) { - wdlist = 0; - iolist = 0; - pushio(argp, f); - e.iobase = e.iop; - yynerrs = 0; - if (setjmp(failpt = rt) == 0 && yyparse() == 0) - rv = execute(outtree, NOPIPE, NOPIPE, 0); - quitenv(); - } - wdlist = swdlist; - iolist = siolist; - failpt = ofail; - outtree = otree; - freearea(areanum--); - return(rv); -} - -/* -------- do.c -------- */ -/* #include "sh.h" */ - -/* - * built-in commands: doX - */ - -int -dolabel() -{ - return(0); -} - -int -dochdir(t) -register struct op *t; -{ - register char *cp, *er; - - if ((cp = t->words[1]) == NULL && (cp = homedir->value) == NULL) - er = ": no home directory"; - else if(chdir(cp) < 0) - er = ": bad directory"; - else - return(0); - prs(cp != NULL? cp: "cd"); - err(er); - return(1); -} - -int -doshift(t) -register struct op *t; -{ - register n; - - n = t->words[1]? getn(t->words[1]): 1; - if(dolc < n) { - err("nothing to shift"); - return(1); - } - dolv[n] = dolv[0]; - dolv += n; - dolc -= n; - setval(lookup("#"), putn(dolc)); - return(0); -} - -/* - * execute login and newgrp directly - */ -int -dologin(t) -struct op *t; -{ - register char *cp; - - if (talking) { - signal(SIGINT, SIG_DFL); - signal(SIGQUIT, SIG_DFL); - } - cp = rexecve(t->words[0], t->words, makenv()); - prs(t->words[0]); prs(": "); err(cp); - return(1); -} - -int -doumask(t) -register struct op *t; -{ - register int i, n; - register char *cp; - - if ((cp = t->words[1]) == NULL) { - i = umask(0); - umask(i); - for (n=3*4; (n-=3) >= 0;) - putc('0'+((i>>n)&07)); - putc('\n'); - } else { - for (n=0; *cp>='0' && *cp<='9'; cp++) - n = n*8 + (*cp-'0'); - umask(n); - } - return(0); -} - -int -doexec(t) -register struct op *t; -{ - register i; - jmp_buf ex; - xint *ofail; - - t->ioact = NULL; - for(i = 0; (t->words[i]=t->words[i+1]) != NULL; i++) - ; - if (i == 0) - return(1); - execflg = 1; - ofail = failpt; - if (setjmp(failpt = ex) == 0) - execute(t, NOPIPE, NOPIPE, FEXEC); - failpt = ofail; - execflg = 0; - return(1); -} - -int -dodot(t) -struct op *t; -{ - register i; - register char *sp, *tp; - char *cp; - - if ((cp = t->words[1]) == NULL) - return(0); - sp = any('/', cp)? ":": path->value; - while (*sp) { - tp = e.linep; - while (*sp && (*tp = *sp++) != ':') - tp++; - if (tp != e.linep) - *tp++ = '/'; - for (i = 0; (*tp++ = cp[i++]) != '\0';) - ; - if ((i = open(e.linep, 0)) >= 0) { - exstat = 0; - next(remap(i)); - return(exstat); - } - } - prs(cp); - err(": not found"); - return(-1); -} - -int -dowait(t) -struct op *t; -{ - register i; - register char *cp; - - if ((cp = t->words[1]) != NULL) { - i = getn(cp); - if (i == 0) - return(0); - } else - i = -1; - setstatus(waitfor(i, 1)); - return(0); -} - -int -doread(t) -struct op *t; -{ - register char *cp, **wp; - register nb; - register int nl = 0; - - if (t->words[1] == NULL) { - err("Usage: read name ..."); - return(1); - } - for (wp = t->words+1; *wp; wp++) { - for (cp = e.linep; !nl && cp < elinep-1; cp++) - if ((nb = read(0, cp, sizeof(*cp))) != sizeof(*cp) || - (nl = (*cp == '\n')) || - (wp[1] && any(*cp, ifs->value))) - break; - *cp = 0; - if (nb <= 0) - break; - setval(lookup(*wp), e.linep); - } - return(nb <= 0); -} - -int -doeval(t) -register struct op *t; -{ - return(RUN(awordlist, t->words+1, wdchar)); -} - -int -dotrap(t) -register struct op *t; -{ - register int n, i; - register int resetsig; - - if (t->words[1] == NULL) { - for (i=0; i<_NSIG; i++) - if (trap[i]) { - prn(i); - prs(": "); - prs(trap[i]); - prs("\n"); - } - return(0); - } - resetsig = digit(*t->words[1]); - for (i = resetsig ? 1 : 2; t->words[i] != NULL; ++i) { - n = getsig(t->words[i]); - xfree(trap[n]); - trap[n] = 0; - if (!resetsig) { - if (*t->words[1] != '\0') { - trap[n] = strsave(t->words[1], 0); - setsig(n, sig); - } else - setsig(n, SIG_IGN); - } else { - if (talking) - if (n == SIGINT) - setsig(n, onintr); - else - setsig(n, n == SIGQUIT ? SIG_IGN - : SIG_DFL); - else - setsig(n, SIG_DFL); - } - } - return(0); -} - -int -getsig(s) -char *s; -{ - register int n; - - if ((n = getn(s)) < 0 || n >= _NSIG) { - err("trap: bad signal number"); - n = 0; - } - return(n); -} - -void -setsig(n, f) -register n; -_PROTOTYPE(void (*f), (int)); -{ - if (n == 0) - return; - if (signal(n, SIG_IGN) != SIG_IGN || ourtrap[n]) { - ourtrap[n] = 1; - signal(n, f); - } -} - -int -getn(as) -char *as; -{ - register char *s; - register n, m; - - s = as; - m = 1; - if (*s == '-') { - m = -1; - s++; - } - for (n = 0; digit(*s); s++) - n = (n*10) + (*s-'0'); - if (*s) { - prs(as); - err(": bad number"); - } - return(n*m); -} - -int -dobreak(t) -struct op *t; -{ - return(brkcontin(t->words[1], 1)); -} - -int -docontinue(t) -struct op *t; -{ - return(brkcontin(t->words[1], 0)); -} - -static int -brkcontin(cp, val) -register char *cp; -int val; -{ - register struct brkcon *bc; - register nl; - - nl = cp == NULL? 1: getn(cp); - if (nl <= 0) - nl = 999; - do { - if ((bc = brklist) == NULL) - break; - brklist = bc->nextlev; - } while (--nl); - if (nl) { - err("bad break/continue level"); - return(1); - } - isbreak = val; - longjmp(bc->brkpt, 1); - /* NOTREACHED */ -} - -int -doexit(t) -struct op *t; -{ - register char *cp; - - execflg = 0; - if ((cp = t->words[1]) != NULL) - setstatus(getn(cp)); - leave(); - /* NOTREACHED */ -} - -int -doexport(t) -struct op *t; -{ - rdexp(t->words+1, export, EXPORT); - return(0); -} - -int -doreadonly(t) -struct op *t; -{ - rdexp(t->words+1, ronly, RONLY); - return(0); -} - -static void -rdexp(wp, f, key) -register char **wp; -void (*f)(); -int key; -{ - if (*wp != NULL) { - for (; *wp != NULL; wp++) - if (checkname(*wp)) - (*f)(lookup(*wp)); - else - badid(*wp); - } else - putvlist(key, 1); -} - -static void -badid(s) -register char *s; -{ - prs(s); - err(": bad identifier"); -} - -int -doset(t) -register struct op *t; -{ - register struct var *vp; - register char *cp; - register n; - - if ((cp = t->words[1]) == NULL) { - for (vp = vlist; vp; vp = vp->next) - varput(vp->name, 1); - return(0); - } - if (*cp == '-') { - /* bad: t->words++; */ - for(n = 0; (t->words[n]=t->words[n+1]) != NULL; n++) - ; - if (*++cp == 0) - flag['x'] = flag['v'] = 0; - else - for (; *cp; cp++) - switch (*cp) { - case 'e': - if (!talking) - flag['e']++; - break; - - default: - if (*cp>='a' && *cp<='z') - flag[*cp]++; - break; - } - setdash(); - } - if (t->words[1]) { - t->words[0] = dolv[0]; - for (n=1; t->words[n]; n++) - setarea((char *)t->words[n], 0); - dolc = n-1; - dolv = t->words; - setval(lookup("#"), putn(dolc)); - setarea((char *)(dolv-1), 0); - } - return(0); -} - -void -varput(s, out) -register char *s; -int out; -{ - if (letnum(*s)) { - write(out, s, strlen(s)); - write(out, "\n", 1); - } -} - - -#define SECS 60L -#define MINS 3600L - -int -dotimes() -{ - struct tms tbuf; - - times(&tbuf); - - prn((int)(tbuf.tms_cutime / MINS)); - prs("m"); - prn((int)((tbuf.tms_cutime % MINS) / SECS)); - prs("s "); - prn((int)(tbuf.tms_cstime / MINS)); - prs("m"); - prn((int)((tbuf.tms_cstime % MINS) / SECS)); - prs("s\n"); - return(0); -} - -struct builtin { - char *command; - int (*fn)(); -}; -static struct builtin builtin[] = { - ":", dolabel, - "cd", dochdir, - "shift", doshift, - "exec", doexec, - "wait", dowait, - "read", doread, - "eval", doeval, - "trap", dotrap, - "break", dobreak, - "continue", docontinue, - "exit", doexit, - "export", doexport, - "readonly", doreadonly, - "set", doset, - ".", dodot, - "umask", doumask, - "login", dologin, - "newgrp", dologin, - "times", dotimes, - 0, -}; - -int (*inbuilt(s))() -register char *s; -{ - register struct builtin *bp; - - for (bp = builtin; bp->command != NULL; bp++) - if (strcmp(bp->command, s) == 0) - return(bp->fn); - return((int(*)())NULL); -} - diff --git a/commands/sh/sh4.c b/commands/sh/sh4.c deleted file mode 100644 index 4fe04df73..000000000 --- a/commands/sh/sh4.c +++ /dev/null @@ -1,779 +0,0 @@ -#define Extern extern -#include -#include -#include -#include -#include -#include -#include -#include "sh.h" - -/* -------- eval.c -------- */ -/* #include "sh.h" */ -/* #include "word.h" */ - -/* - * ${} - * `command` - * blank interpretation - * quoting - * glob - */ - -_PROTOTYPE(static int expand, (char *cp, struct wdblock **wbp, int f )); -_PROTOTYPE(static char *blank, (int f )); -_PROTOTYPE(static int dollar, (int quoted )); -_PROTOTYPE(static int grave, (int quoted )); -_PROTOTYPE(void globname, (char *we, char *pp )); -_PROTOTYPE(static char *generate, (char *start1, char *end1, char *middle, char *end )); -_PROTOTYPE(static int anyspcl, (struct wdblock *wb )); -_PROTOTYPE(static int xstrcmp, (char *p1, char *p2 )); -_PROTOTYPE(void glob0, (char *a0, unsigned int a1, int a2, int (*a3)(char *, char *))); -_PROTOTYPE(void glob1, (char *base, char *lim )); -_PROTOTYPE(void glob2, (char *i, char *j )); -_PROTOTYPE(void glob3, (char *i, char *j, char *k )); -_PROTOTYPE(char *memcopy, (char *ato, char *from, int nb )); - -char ** -eval(ap, f) -register char **ap; -int f; -{ - struct wdblock *wb; - char **wp; - char **wf; - jmp_buf ev; - - wp = NULL; - wb = NULL; - wf = NULL; - if (newenv(setjmp(errpt = ev)) == 0) { - while (*ap && isassign(*ap)) - expand(*ap++, &wb, f & ~DOGLOB); - if (flag['k']) { - for (wf = ap; *wf; wf++) { - if (isassign(*wf)) - expand(*wf, &wb, f & ~DOGLOB); - } - } - for (wb = addword((char *)0, wb); *ap; ap++) { - if (!flag['k'] || !isassign(*ap)) - expand(*ap, &wb, f & ~DOKEY); - } - wb = addword((char *)0, wb); - wp = getwords(wb); - quitenv(); - } else - gflg = 1; - return(gflg? (char **)NULL: wp); -} - -/* - * Make the exported environment from the exported - * names in the dictionary. Keyword assignments - * will already have been done. - */ -char ** -makenv() - -{ - register struct wdblock *wb; - register struct var *vp; - - wb = NULL; - for (vp = vlist; vp; vp = vp->next) - if (vp->status & EXPORT) - wb = addword(vp->name, wb); - wb = addword((char *)0, wb); - return(getwords(wb)); -} - -char * -evalstr(cp, f) -register char *cp; -int f; -{ - struct wdblock *wb; - - wb = NULL; - if (expand(cp, &wb, f)) { - if (wb == NULL || wb->w_nword == 0 || (cp = wb->w_words[0]) == NULL) - cp = ""; - DELETE(wb); - } else - cp = NULL; - return(cp); -} - -static int -expand(cp, wbp, f) -register char *cp; -register struct wdblock **wbp; -int f; -{ - jmp_buf ev; - - gflg = 0; - if (cp == NULL) - return(0); - if (!anys("$`'\"", cp) && - !anys(ifs->value, cp) && - ((f&DOGLOB)==0 || !anys("[*?", cp))) { - cp = strsave(cp, areanum); - if (f & DOTRIM) - unquote(cp); - *wbp = addword(cp, *wbp); - return(1); - } - if (newenv(setjmp(errpt = ev)) == 0) { - PUSHIO(aword, cp, strchar); - e.iobase = e.iop; - while ((cp = blank(f)) && gflg == 0) { - e.linep = cp; - cp = strsave(cp, areanum); - if ((f&DOGLOB) == 0) { - if (f & DOTRIM) - unquote(cp); - *wbp = addword(cp, *wbp); - } else - *wbp = glob(cp, *wbp); - } - quitenv(); - } else - gflg = 1; - return(gflg == 0); -} - -/* - * Blank interpretation and quoting - */ -static char * -blank(f) -int f; -{ - register c, c1; - register char *sp; - int scanequals, foundequals; - - sp = e.linep; - scanequals = f & DOKEY; - foundequals = 0; - -loop: - switch (c = subgetc('"', foundequals)) { - case 0: - if (sp == e.linep) - return(0); - *e.linep++ = 0; - return(sp); - - default: - if (f & DOBLANK && any(c, ifs->value)) - goto loop; - break; - - case '"': - case '\'': - scanequals = 0; - if (INSUB()) - break; - for (c1 = c; (c = subgetc(c1, 1)) != c1;) { - if (c == 0) - break; - if (c == '\'' || !any(c, "$`\"")) - c |= QUOTE; - *e.linep++ = c; - } - c = 0; - } - unget(c); - if (!letter(c)) - scanequals = 0; - for (;;) { - c = subgetc('"', foundequals); - if (c == 0 || - (f & DOBLANK && any(c, ifs->value)) || - (!INSUB() && any(c, "\"'"))) { - scanequals = 0; - unget(c); - if (any(c, "\"'")) - goto loop; - break; - } - if (scanequals) - if (c == '=') { - foundequals = 1; - scanequals = 0; - } - else if (!letnum(c)) - scanequals = 0; - *e.linep++ = c; - } - *e.linep++ = 0; - return(sp); -} - -/* - * Get characters, substituting for ` and $ - */ -int -subgetc(ec, quoted) -register char ec; -int quoted; -{ - register char c; - -again: - c = getc(ec); - if (!INSUB() && ec != '\'') { - if (c == '`') { - if (grave(quoted) == 0) - return(0); - e.iop->task = XGRAVE; - goto again; - } - if (c == '$' && (c = dollar(quoted)) == 0) { - e.iop->task = XDOLL; - goto again; - } - } - return(c); -} - -/* - * Prepare to generate the string returned by ${} substitution. - */ -static int -dollar(quoted) -int quoted; -{ - int otask; - struct io *oiop; - char *dolp; - register char *s, c, *cp; - struct var *vp; - - c = readc(); - s = e.linep; - if (c != '{') { - *e.linep++ = c; - if (letter(c)) { - while ((c = readc())!=0 && letnum(c)) - if (e.linep < elinep) - *e.linep++ = c; - unget(c); - } - c = 0; - } else { - oiop = e.iop; - otask = e.iop->task; - e.iop->task = XOTHER; - while ((c = subgetc('"', 0))!=0 && c!='}' && c!='\n') - if (e.linep < elinep) - *e.linep++ = c; - if (oiop == e.iop) - e.iop->task = otask; - if (c != '}') { - err("unclosed ${"); - gflg++; - return(c); - } - } - if (e.linep >= elinep) { - err("string in ${} too long"); - gflg++; - e.linep -= 10; - } - *e.linep = 0; - if (*s) - for (cp = s+1; *cp; cp++) - if (any(*cp, "=-+?")) { - c = *cp; - *cp++ = 0; - break; - } - if (s[1] == 0 && (*s == '*' || *s == '@')) { - if (dolc > 1) { - /* currently this does not distinguish $* and $@ */ - /* should check dollar */ - e.linep = s; - PUSHIO(awordlist, dolv+1, dolchar); - return(0); - } else { /* trap the nasty ${=} */ - s[0] = '1'; - s[1] = 0; - } - } - e.linep = s; - vp = lookup(s); - if ((dolp = vp->value) == null) { - switch (c) { - case '=': - if (digit(*s)) { - err("cannot use ${...=...} with $n"); - gflg++; - break; - } - cp = evalstr(strsave(cp, areanum),DOSUB); - setval(vp, cp); - dolp = vp->value; - break; - - case '-': - dolp = evalstr(strsave(cp, areanum),DOSUB); - break; - - case '?': - if (*cp == 0) { - prs("missing value for "); - err(s); - } else - err(evalstr(strsave(cp, areanum),DOSUB)); - gflg++; - break; - } - } else if (c == '+') { - dolp = evalstr(strsave(cp, areanum),DOSUB); - } - if (flag['u'] && dolp == null) { - prs("unset variable: "); - err(s); - gflg++; - } - PUSHIO(aword, dolp, quoted ? qstrchar : strchar); - return(0); -} - -/* - * Run the command in `...` and read its output. - */ -static int -grave(quoted) -int quoted; -{ - int otask; - struct io *oiop; - register char *cp,*s; - register int i,c; - int pf[2]; - - c = readc(); - s = e.linep; - *e.linep++ = c; - oiop = e.iop; - otask = e.iop->task; - e.iop->task = XOTHER; - while ((c = subgetc('\'', 0))!=0 && c!='`') - if (e.linep < elinep) - *e.linep++ = c; - if (oiop == e.iop) - e.iop->task = otask; - if (c != '`') { - err("no closing `"); - return(0); - } - if (openpipe(pf) < 0) - return(0); - if ((i = fork()) == -1) { - closepipe(pf); - err("try again"); - return(0); - } - if (i != 0) { - e.linep = s; - close(pf[1]); - PUSHIO(afile, remap(pf[0]), quoted? qgravechar: gravechar); - return(1); - } - *e.linep = 0; - /* allow trapped signals */ - for (i=0; i<_NSIG; i++) - if (ourtrap[i] && signal(i, SIG_IGN) != SIG_IGN) - signal(i, SIG_DFL); - dup2(pf[1], 1); - closepipe(pf); - flag['e'] = 0; - flag['v'] = 0; - flag['n'] = 0; - cp = strsave(e.linep = s, 0); - areanum = 1; - inithere(); - freearea(areanum); /* free old space */ - e.oenv = NULL; - e.iop = (e.iobase = iostack) - 1; - unquote(cp); - talking = 0; - PUSHIO(aword, cp, nlchar); - onecommand(); - exit(1); -} - -char * -unquote(as) -register char *as; -{ - register char *s; - - if ((s = as) != NULL) - while (*s) - *s++ &= ~QUOTE; - return(as); -} - -/* -------- glob.c -------- */ -/* #include "sh.h" */ - -/* - * glob - */ - -#define scopy(x) strsave((x), areanum) -#define BLKSIZ 512 -#define NDENT ((BLKSIZ+sizeof(struct direct)-1)/sizeof(struct direct)) - -static struct wdblock *cl, *nl; -static char spcl[] = "[?*"; - -struct wdblock * -glob(cp, wb) -char *cp; -struct wdblock *wb; -{ - register i; - register char *pp; - - if (cp == 0) - return(wb); - i = 0; - for (pp = cp; *pp; pp++) - if (any(*pp, spcl)) - i++; - else if (!any(*pp & ~QUOTE, spcl)) - *pp &= ~QUOTE; - if (i != 0) { - for (cl = addword(scopy(cp), (struct wdblock *)0); anyspcl(cl); cl = nl) { - nl = newword(cl->w_nword*2); - for(i=0; iw_nword; i++) { /* for each argument */ - for (pp = cl->w_words[i]; *pp; pp++) - if (any(*pp, spcl)) { - globname(cl->w_words[i], pp); - break; - } - if (*pp == '\0') - nl = addword(scopy(cl->w_words[i]), nl); - } - for(i=0; iw_nword; i++) - DELETE(cl->w_words[i]); - DELETE(cl); - } - for(i=0; iw_nword; i++) - unquote(cl->w_words[i]); - glob0((char *)cl->w_words, cl->w_nword, sizeof(char *), xstrcmp); - if (cl->w_nword) { - for (i=0; iw_nword; i++) - wb = addword(cl->w_words[i], wb); - DELETE(cl); - return(wb); - } - } - wb = addword(unquote(cp), wb); - return(wb); -} - -void -globname(we, pp) -char *we; -register char *pp; -{ - register char *np, *cp; - char *name, *gp, *dp; - int dn, j, n, k; - struct direct ent[NDENT]; - char dname[NAME_MAX+1]; - struct stat dbuf; - - for (np = we; np != pp; pp--) - if (pp[-1] == '/') - break; - for (dp = cp = space((int)(pp-np)+3); np < pp;) - *cp++ = *np++; - *cp++ = '.'; - *cp = '\0'; - for (gp = cp = space(strlen(pp)+1); *np && *np != '/';) - *cp++ = *np++; - *cp = '\0'; - dn = open(dp, 0); - if (dn < 0) { - DELETE(dp); - DELETE(gp); - return; - } - dname[NAME_MAX] = '\0'; - while ((n = read(dn, (char *)ent, sizeof(ent))) >= sizeof(*ent)) { - n /= sizeof(*ent); - for (j=0; jw_words; - for (i=0; iw_nword; i++) - if (anys(spcl, *wd++)) - return(1); - return(0); -} - -static int -xstrcmp(p1, p2) -char *p1, *p2; -{ - return(strcmp(*(char **)p1, *(char **)p2)); -} - -/* -------- word.c -------- */ -/* #include "sh.h" */ -/* #include "word.h" */ - -#define NSTART 16 /* default number of words to allow for initially */ - -struct wdblock * -newword(nw) -register int nw; -{ - register struct wdblock *wb; - - wb = (struct wdblock *) space(sizeof(*wb) + nw*sizeof(char *)); - wb->w_bsize = nw; - wb->w_nword = 0; - return(wb); -} - -struct wdblock * -addword(wd, wb) -char *wd; -register struct wdblock *wb; -{ - register struct wdblock *wb2; - register nw; - - if (wb == NULL) - wb = newword(NSTART); - if ((nw = wb->w_nword) >= wb->w_bsize) { - wb2 = newword(nw * 2); - memcopy((char *)wb2->w_words, (char *)wb->w_words, nw*sizeof(char *)); - wb2->w_nword = nw; - DELETE(wb); - wb = wb2; - } - wb->w_words[wb->w_nword++] = wd; - return(wb); -} - -char ** -getwords(wb) -register struct wdblock *wb; -{ - register char **wd; - register nb; - - if (wb == NULL) - return((char **)NULL); - if (wb->w_nword == 0) { - DELETE(wb); - return((char **)NULL); - } - wd = (char **) space(nb = sizeof(*wd) * wb->w_nword); - memcopy((char *)wd, (char *)wb->w_words, nb); - DELETE(wb); /* perhaps should done by caller */ - return(wd); -} - -_PROTOTYPE(int (*func), (char *, char *)); -int globv; - -void -glob0(a0, a1, a2, a3) -char *a0; -unsigned a1; -int a2; -_PROTOTYPE(int (*a3), (char *, char *)); -{ - func = a3; - globv = a2; - glob1(a0, a0 + a1 * a2); -} - -void -glob1(base, lim) -char *base, *lim; -{ - register char *i, *j; - int v2; - char *lptr, *hptr; - int c; - unsigned n; - - - v2 = globv; - -top: - if ((n=(int)(lim-base)) <= v2) - return; - n = v2 * (n / (2*v2)); - hptr = lptr = base+n; - i = base; - j = lim-v2; - for(;;) { - if (i < lptr) { - if ((c = (*func)(i, lptr)) == 0) { - glob2(i, lptr -= v2); - continue; - } - if (c < 0) { - i += v2; - continue; - } - } - -begin: - if (j > hptr) { - if ((c = (*func)(hptr, j)) == 0) { - glob2(hptr += v2, j); - goto begin; - } - if (c > 0) { - if (i == lptr) { - glob3(i, hptr += v2, j); - i = lptr += v2; - goto begin; - } - glob2(i, j); - j -= v2; - i += v2; - continue; - } - j -= v2; - goto begin; - } - - - if (i == lptr) { - if (lptr-base >= lim-hptr) { - glob1(hptr+v2, lim); - lim = lptr; - } else { - glob1(base, lptr); - base = hptr+v2; - } - goto top; - } - - - glob3(j, lptr -= v2, i); - j = hptr -= v2; - } -} - -void -glob2(i, j) -char *i, *j; -{ - register char *index1, *index2, c; - int m; - - m = globv; - index1 = i; - index2 = j; - do { - c = *index1; - *index1++ = *index2; - *index2++ = c; - } while(--m); -} - -void -glob3(i, j, k) -char *i, *j, *k; -{ - register char *index1, *index2, *index3; - int c; - int m; - - m = globv; - index1 = i; - index2 = j; - index3 = k; - do { - c = *index1; - *index1++ = *index3; - *index3++ = *index2; - *index2++ = c; - } while(--m); -} - -char * -memcopy(ato, from, nb) -register char *ato, *from; -register int nb; -{ - register char *to; - - to = ato; - while (--nb >= 0) - *to++ = *from++; - return(ato); -} diff --git a/commands/sh/sh5.c b/commands/sh/sh5.c deleted file mode 100644 index 6e454bb3a..000000000 --- a/commands/sh/sh5.c +++ /dev/null @@ -1,681 +0,0 @@ -#define Extern extern -#include -#include -#include -#include -#include "sh.h" - -/* -------- io.c -------- */ -/* #include "sh.h" */ - -/* - * shell IO - */ - -static struct iobuf sharedbuf = {AFID_NOBUF}; -static struct iobuf mainbuf = {AFID_NOBUF}; -static unsigned bufid = AFID_ID; /* buffer id counter */ - -struct ioarg temparg = {0, 0, 0, AFID_NOBUF, 0}; - -_PROTOTYPE(static void readhere, (char **name, char *s, int ec )); -_PROTOTYPE(void pushio, (struct ioarg *argp, int (*fn)())); -_PROTOTYPE(static int xxchar, (struct ioarg *ap )); -_PROTOTYPE(void tempname, (char *tname )); - -int -getc(ec) -register int ec; -{ - register int c; - - if(e.linep > elinep) { - while((c=readc()) != '\n' && c) - ; - err("input line too long"); - gflg++; - return(c); - } - c = readc(); - if (ec != '\'' && e.iop->task != XGRAVE) { - if(c == '\\') { - c = readc(); - if (c == '\n' && ec != '\"') - return(getc(ec)); - c |= QUOTE; - } - } - return(c); -} - -void -unget(c) -int c; -{ - if (e.iop >= e.iobase) - e.iop->peekc = c; -} - -int -eofc() - -{ - return e.iop < e.iobase || (e.iop->peekc == 0 && e.iop->prev == 0); -} - -int -readc() -{ - register c; - - for (; e.iop >= e.iobase; e.iop--) - if ((c = e.iop->peekc) != '\0') { - e.iop->peekc = 0; - return(c); - } - else { - if (e.iop->prev != 0) { - if ((c = (*e.iop->iofn)(e.iop->argp, e.iop)) != '\0') { - if (c == -1) { - e.iop++; - continue; - } - if (e.iop == iostack) - ioecho(c); - return(e.iop->prev = c); - } - else if (e.iop->task == XIO && e.iop->prev != '\n') { - e.iop->prev = 0; - if (e.iop == iostack) - ioecho('\n'); - return '\n'; - } - } - if (e.iop->task == XIO) { - if (multiline) - return e.iop->prev = 0; - if (talking && e.iop == iostack+1) - prs(prompt->value); - } - } - if (e.iop >= iostack) - return(0); - leave(); - /* NOTREACHED */ -} - -void -ioecho(c) -char c; -{ - if (flag['v']) - write(2, &c, sizeof c); -} - -void -pushio(argp, fn) -struct ioarg *argp; -int (*fn)(); -{ - if (++e.iop >= &iostack[NPUSH]) { - e.iop--; - err("Shell input nested too deeply"); - gflg++; - return; - } - e.iop->iofn = fn; - - if (argp->afid != AFID_NOBUF) - e.iop->argp = argp; - else { - e.iop->argp = ioargstack + (e.iop - iostack); - *e.iop->argp = *argp; - e.iop->argp->afbuf = e.iop == &iostack[0] ? &mainbuf : &sharedbuf; - if (isatty(e.iop->argp->afile) == 0 && - (e.iop == &iostack[0] || - lseek(e.iop->argp->afile, 0L, 1) != -1)) { - if (++bufid == AFID_NOBUF) - bufid = AFID_ID; - e.iop->argp->afid = bufid; - } - } - - e.iop->prev = ~'\n'; - e.iop->peekc = 0; - e.iop->xchar = 0; - e.iop->nlcount = 0; - if (fn == filechar || fn == linechar) - e.iop->task = XIO; - else if (fn == gravechar || fn == qgravechar) - e.iop->task = XGRAVE; - else - e.iop->task = XOTHER; -} - -struct io * -setbase(ip) -struct io *ip; -{ - register struct io *xp; - - xp = e.iobase; - e.iobase = ip; - return(xp); -} - -/* - * Input generating functions - */ - -/* - * Produce the characters of a string, then a newline, then EOF. - */ -int -nlchar(ap) -register struct ioarg *ap; -{ - register int c; - - if (ap->aword == NULL) - return(0); - if ((c = *ap->aword++) == 0) { - ap->aword = NULL; - return('\n'); - } - return(c); -} - -/* - * Given a list of words, produce the characters - * in them, with a space after each word. - */ -int -wdchar(ap) -register struct ioarg *ap; -{ - register char c; - register char **wl; - - if ((wl = ap->awordlist) == NULL) - return(0); - if (*wl != NULL) { - if ((c = *(*wl)++) != 0) - return(c & 0177); - ap->awordlist++; - return(' '); - } - ap->awordlist = NULL; - return('\n'); -} - -/* - * Return the characters of a list of words, - * producing a space between them. - */ -int -dolchar(ap) -register struct ioarg *ap; -{ - register char *wp; - - if ((wp = *ap->awordlist++) != NULL) { - PUSHIO(aword, wp, *ap->awordlist == NULL? strchar: xxchar); - return(-1); - } - return(0); -} - -static int -xxchar(ap) -register struct ioarg *ap; -{ - register int c; - - if (ap->aword == NULL) - return(0); - if ((c = *ap->aword++) == '\0') { - ap->aword = NULL; - return(' '); - } - return(c); -} - -/* - * Produce the characters from a single word (string). - */ -int -strchar(ap) -register struct ioarg *ap; -{ - register int c; - - if (ap->aword == NULL || (c = *ap->aword++) == 0) - return(0); - return(c); -} - -/* - * Produce quoted characters from a single word (string). - */ -int -qstrchar(ap) -register struct ioarg *ap; -{ - register int c; - - if (ap->aword == NULL || (c = *ap->aword++) == 0) - return(0); - return(c|QUOTE); -} - -/* - * Return the characters from a file. - */ -int -filechar(ap) -register struct ioarg *ap; -{ - register int i; - char c; - struct iobuf *bp = ap->afbuf; - - if (ap->afid != AFID_NOBUF) { - if ((i = ap->afid != bp->id) || bp->bufp == bp->ebufp) { - if (i) - lseek(ap->afile, ap->afpos, 0); - do { - i = read(ap->afile, bp->buf, sizeof(bp->buf)); - } while (i < 0 && errno == EINTR); - if (i <= 0) { - closef(ap->afile); - return 0; - } - bp->id = ap->afid; - bp->ebufp = (bp->bufp = bp->buf) + i; - } - ap->afpos++; - return *bp->bufp++ & 0177; - } - - do { - i = read(ap->afile, &c, sizeof(c)); - } while (i < 0 && errno == EINTR); - return(i == sizeof(c)? c&0177: (closef(ap->afile), 0)); -} - -/* - * Return the characters from a here temp file. - */ -int -herechar(ap) -register struct ioarg *ap; -{ - char c; - - - if (read(ap->afile, &c, sizeof(c)) != sizeof(c)) { - close(ap->afile); - c = 0; - } - return (c); - -} - -/* - * Return the characters produced by a process (`...`). - * Quote them if required, and remove any trailing newline characters. - */ -int -gravechar(ap, iop) -struct ioarg *ap; -struct io *iop; -{ - register int c; - - if ((c = qgravechar(ap, iop)&~QUOTE) == '\n') - c = ' '; - return(c); -} - -int -qgravechar(ap, iop) -register struct ioarg *ap; -struct io *iop; -{ - register int c; - - if (iop->xchar) { - if (iop->nlcount) { - iop->nlcount--; - return('\n'|QUOTE); - } - c = iop->xchar; - iop->xchar = 0; - } else if ((c = filechar(ap)) == '\n') { - iop->nlcount = 1; - while ((c = filechar(ap)) == '\n') - iop->nlcount++; - iop->xchar = c; - if (c == 0) - return(c); - iop->nlcount--; - c = '\n'; - } - return(c!=0? c|QUOTE: 0); -} - -/* - * Return a single command (usually the first line) from a file. - */ -int -linechar(ap) -register struct ioarg *ap; -{ - register int c; - - if ((c = filechar(ap)) == '\n') { - if (!multiline) { - closef(ap->afile); - ap->afile = -1; /* illegal value */ - } - } - return(c); -} - -void -prs(s) -register char *s; -{ - if (*s) - write(2, s, strlen(s)); -} - -void -putc(c) -char c; -{ - write(2, &c, sizeof c); -} - -void -prn(u) -unsigned u; -{ - prs(itoa(u, 0)); -} - -void -closef(i) -register int i; -{ - if (i > 2) - close(i); -} - -void -closeall() -{ - register u; - - for (u=NUFILE; u= 0 && fd < e.iofd); - for (i=0; ih_tag = evalstr(s, DOSUB); - if (h->h_tag == 0) - return; - h->h_iop = iop; - iop->io_name = 0; - h->h_next = NULL; - if (inhere == 0) - inhere = h; - else - for (lh = inhere; lh!=NULL; lh = lh->h_next) - if (lh->h_next == 0) { - lh->h_next = h; - break; - } - iop->io_flag |= IOHERE|IOXHERE; - for (s = h->h_tag; *s; s++) - if (*s & QUOTE) { - iop->io_flag &= ~ IOXHERE; - *s &= ~ QUOTE; - } - h->h_dosub = iop->io_flag & IOXHERE; -} - -void -gethere() -{ - register struct here *h, *hp; - - /* Scan here files first leaving inhere list in place */ - for (hp = h = inhere; h != NULL; hp = h, h = h->h_next) - readhere(&h->h_iop->io_name, h->h_tag, h->h_dosub? 0: '\''); - - /* Make inhere list active - keep list intact for scraphere */ - if (hp != NULL) { - hp->h_next = acthere; - acthere = inhere; - inhere = NULL; - } -} - -static void -readhere(name, s, ec) -char **name; -register char *s; -int ec; -{ - int tf; - char tname[30]; - register c; - jmp_buf ev; - char line [LINELIM+1]; - char *next; - - tempname(tname); - *name = strsave(tname, areanum); - tf = creat(tname, 0600); - if (tf < 0) - return; - if (newenv(setjmp(errpt = ev)) != 0) - unlink(tname); - else { - pushio(e.iop->argp, e.iop->iofn); - e.iobase = e.iop; - for (;;) { - if (talking && e.iop <= iostack) - prs(cprompt->value); - next = line; - while ((c = readc()) != '\n' && c) { - if (next >= &line[LINELIM]) { - c = 0; - break; - } - *next++ = c; - } - *next = 0; - if (strcmp(s, line) == 0 || c == 0) - break; - *next++ = '\n'; - write (tf, line, (int)(next-line)); - } - if (c == 0) { - prs("here document `"); prs(s); err("' unclosed"); - } - quitenv(); - } - close(tf); -} - -/* - * open here temp file. - * if unquoted here, expand here temp file into second temp file. - */ -int -herein(hname, xdoll) -char *hname; -int xdoll; -{ - register hf, tf; - - if (hname == 0) - return(-1); - hf = open(hname, 0); - if (hf < 0) - return (-1); - if (xdoll) { - char c; - char tname[30]; - jmp_buf ev; - - tempname(tname); - if ((tf = creat(tname, 0600)) < 0) - return (-1); - if (newenv(setjmp(errpt = ev)) == 0) { - PUSHIO(afile, hf, herechar); - setbase(e.iop); - while ((c = subgetc(0, 0)) != 0) { - char c1 = c&~QUOTE; - - if (c"E && !any(c1,"`$\\")) - write(tf,"\\",1); - write(tf, &c1, 1); - } - quitenv(); - } else - unlink(tname); - close(tf); - tf = open(tname, 0); - unlink(tname); - return (tf); - } else - return (hf); -} - -void -scraphere() -{ - register struct here *h; - - for (h = inhere; h != NULL; h = h->h_next) { - if (h->h_iop && h->h_iop->io_name) - unlink(h->h_iop->io_name); - } - inhere = NULL; -} - -/* unlink here temp files before a freearea(area) */ -void -freehere(area) -int area; -{ - register struct here *h, *hl; - - hl = NULL; - for (h = acthere; h != NULL; h = h->h_next) - if (getarea((char *) h) >= area) { - if (h->h_iop->io_name != NULL) - unlink(h->h_iop->io_name); - if (hl == NULL) - acthere = h->h_next; - else - hl->h_next = h->h_next; - } else - hl = h; -} - -void -tempname(tname) -char *tname; -{ - static int inc; - register char *cp, *lp; - - for (cp = tname, lp = "/tmp/shtm"; (*cp = *lp++) != '\0'; cp++) - ; - lp = putn(getpid()*1000 + inc++); - for (; (*cp = *lp++) != '\0'; cp++) - ; -} diff --git a/commands/sh/sh6.c b/commands/sh/sh6.c deleted file mode 100644 index 802be748d..000000000 --- a/commands/sh/sh6.c +++ /dev/null @@ -1,8 +0,0 @@ -#define Extern - -#include -#include -#include -#include -#include "sh.h" - diff --git a/commands/shar/Makefile b/commands/shar/Makefile new file mode 100644 index 000000000..db7387d87 --- /dev/null +++ b/commands/shar/Makefile @@ -0,0 +1,4 @@ +PROG= shar +MAN= + +.include diff --git a/commands/simple/shar.c b/commands/shar/shar.c similarity index 100% rename from commands/simple/shar.c rename to commands/shar/shar.c diff --git a/commands/simple/Makefile b/commands/simple/Makefile deleted file mode 100644 index 69111c993..000000000 --- a/commands/simple/Makefile +++ /dev/null @@ -1,1730 +0,0 @@ -# Makefile for commands/simple. - -CFLAGS = -D_MINIX -D_POSIX_SOURCE -SYS = ../.. -SERVERS = ../../servers -CCLD = $(CC) -i $(CFLAGS) -CC = exec cc - -# This Makefile is large, but that is because it lists all actions that must -# be taken to compile and install all the simple commands. If there were only -# one command then it would look like this: -# -# ALL = \ -# cat \ need the 'cat' executable -# -# all: $(ALL) default rule, make all binaries -# -# cat: cat.c 'cat' is made from 'cat.c' -# $(CCLD) -o $@ $< compile 'cat.c' ($<) to 'cat' ($@) -# install -S 4kw $@ stack size is 8k (8086) or 16k (others) -# -# install: \ rule to install all binaries -# /usr/bin/cat \ one can find 'cat' in /usr/bin -# /bin/cat \ important binaries are also in /bin -# -# /usr/bin/cat: cat -# install -cs -o bin $< $@ copy 'cat' to '/usr/bin/cat' (-c), -# strip symbol table (-s) -# -# /bin/cat: /usr/bin/cat -# install -l h -cs $< $@ install '/bin/cat' by linking (if possible) -# or copying (otherwise) -# -# Some of the binaries are installed under more than one name. The extra -# names are indented by one extra tab in the install rule. -# If you want to add a command then insert it at the appropriate position -# in sorted order. Search around for the command just above or below the -# the new command and add new rules for the new command near those places. -# Observe four key things: -# What to make, how to make, what to install, how to install. - -ALL = \ - add_route \ - arp \ - at \ - backup \ - badblocks \ - banner \ - basename \ - cal \ - calendar \ - cat \ - cdiff \ - cdprobe \ - cgrep \ - chmem \ - chmod \ - chown \ - chroot \ - ci \ - cksum \ - cleantmp \ - cmp \ - co \ - comm \ - compress \ - cp \ - crc \ - cut \ - dd \ - decomp16 \ - dev2name \ - devsize \ - df \ - dhrystone \ - diff \ - dirname \ - du \ - dumpcore \ - ed \ - eject \ - env \ - expand \ - factor \ - fgrep \ - file \ - find \ - finger \ - fix \ - fold \ - fortune \ - fsck \ - fsck1 \ - getty \ - gomoku \ - grep \ - head \ - host \ - hostaddr \ - id \ - ifconfig \ - ifdef \ - in.fingerd \ - in.rshd \ - installx \ - intr \ - ipcs \ - ipcrm \ - irdpd \ - isoread \ - join \ - kill \ - last \ - leave \ - life \ - loadramdisk \ - login \ - look \ - lp \ - lpd \ - ls \ - lspci \ - mail \ - man \ - mesg \ - mkdir \ - mkfifo \ - mkfs \ - mknod \ - mkproto \ - modem \ - mount \ - mt \ - nm \ - newroot \ - nohup \ - nonamed \ - nice \ - od \ - passwd \ - paste \ - ping \ - pr \ - pr_routes \ - progressbar \ - prep \ - printf \ - printroot \ - proto \ - pwd \ - pwdauth \ - ramdisk \ - rarpd \ - rcp \ - rawspeed \ - rdate \ - readall \ - rev \ - readfs \ - remsync \ - rget \ - rlogin \ - rmdir \ - rsh \ - sed \ - shar \ - size \ - sleep \ - slip \ - sort \ - split \ - stat \ - strings \ - strip \ - stty \ - su \ - sum \ - swapfs \ - sync \ - synctree \ - sysenv \ - tail \ - tcpd \ - tcpdp \ - tcpstat \ - tee \ - term \ - termcap \ - tget \ - time \ - touch \ - top \ - tr \ - truncate \ - tsort \ - ttt \ - tty \ - udpstat \ - umount \ - uname \ - unexpand \ - uniq \ - update \ - uud \ - uue \ - vol \ - wc \ - which \ - who \ - whoami \ - write \ - writeisofs \ - xargs \ - yes \ - # - -all: $(ALL) - -add_route: add_route.c - $(CCLD) -o $@ add_route.c - @install -S 4kw $@ - -arp: arp.c - $(CCLD) -o $@ arp.c - -at: at.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -backup: backup.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -badblocks: badblocks.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -banner: banner.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -basename: basename.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -cal: cal.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -calendar: calendar.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -cat: cat.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -cdiff: cdiff.c - $(CCLD) -o $@ $< - @install -S 28kw $@ - -cdprobe: cdprobe.c - $(CCLD) -o $@ $< - @install -S 28kw $@ - -cgrep: cgrep.c - $(CCLD) -o $@ $< - @install -S 5kw $@ - -chmem: chmem.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -chmod: chmod.c - $(CCLD) -o $@ $< - @install -S 16kw $@ - -chown: chown.c - $(CCLD) -o $@ $< - @install -S 16kw $@ - -chroot: chroot.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -ci: ci.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -cksum: cksum.c - $(CCLD) -o $@ $< - @install -S 8kw $@ - -cleantmp: cleantmp.c - $(CCLD) -o $@ $< - @install -S 8kw $@ - -cmp: cmp.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -co: co.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -comm: comm.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -compress: compress.c - $(CCLD) -o $@ $< - @install -S 450k $@ - -cp: cp.c - $(CCLD) -o $@ $< - @install -S 32kw $@ - -crc: crc.c - $(CCLD) -o $@ $< - @install -S 8kw $@ - -cut: cut.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -dd: dd.c - $(CCLD) -o $@ $< - @install -S 20kw $@ - -decomp16: decomp16.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -dev2name: dev2name.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -devsize: devsize.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -df: df.c - $(CCLD) -I$(SYS) -o $@ $< - @install -S 4kw $@ - -dhrystone: dhrystone.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -diff: diff.c - $(CCLD) -o $@ $< - @install -S 512kw $@ - -dirname: dirname.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -du: du.c - $(CCLD) -o $@ $< - @install -S 256kw $@ - -dumpcore: dumpcore.c - $(CCLD) -o $@ $< - @install -S 32k $@ - -ed: ed.c - $(CCLD) -o $@ $< - @install -S 32kw $@ - -eject: eject.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -env: env.c - $(CCLD) -o $@ $< - @install -S 50k $@ - -expand: expand.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -factor: factor.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -fgrep: fgrep.c - $(CCLD) -o $@ $< - @install -S 10kw $@ - -file: file.c - $(CCLD) -o $@ $< - @install -S 25kw $@ - -find: find.c - $(CCLD) -o $@ $< - @install -S 25kw $@ - -finger: finger.c - $(CCLD) -o $@ finger.c - @install -S 8kw $@ - -fix: fix.c - $(CCLD) -o $@ fix.c - @install -S 32kw $@ - -fold: fold.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -fortune: fortune.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -fsck: fsck.c - $(CCLD) -o $@ $< - @install -S 8192k $@ - -fsck1: fsck1.c - $(CCLD) -o $@ $< - @install -S 32kw $@ - -getty: getty.c /usr/include/minix/config.h - $(CCLD) -o $@ getty.c - @install -S 4kw $@ - -gomoku: gomoku.c - $(CCLD) -o $@ $< -lcurses - @install -S 8kw $@ - -grep: grep.c - $(CCLD) -o $@ $< - @install -S 32kw $@ - -head: head.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -host: host.c - $(CCLD) -wo -o $@ host.c - @install -S 4kw $@ - -hostaddr: hostaddr.c - $(CCLD) -o $@ hostaddr.c - @install -S 8kw $@ - -id: id.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -ifconfig: ifconfig.c - $(CCLD) -o $@ ifconfig.c - @install -S 4kw $@ - -ifdef: ifdef.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -in.fingerd: in.fingerd.c - $(CCLD) -o $@ in.fingerd.c - @install -S 4kw $@ - -in.rshd: in.rshd.c - $(CCLD) -o $@ in.rshd.c - @install -S 8kw $@ - -installx: install.c # Note: avoided confict with 'install' rule. - $(CCLD) -o $@ install.c - -intr: intr.c - $(CCLD) -o $@ intr.c - @install -S 4kw $@ - -ipcs: ipcs.c - $(CCLD) -o $@ ipcs.c - @install -S 4kw $@ - -ipcrm: ipcrm.c - $(CCLD) -o $@ ipcrm.c - @install -S 4kw $@ - -irdpd: irdpd.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -isoread: isoread.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -join: join.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -kill: kill.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -last: last.c - $(CCLD) -o $@ $< - @install -S 5kw $@ - -leave: leave.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -life: life.c - $(CCLD) -o $@ $< -lcurses - @install -S 15kw $@ - -loadramdisk: loadramdisk.c - $(CCLD) -o $@ $< - install -S 4kw $@ - -login: login.c - $(CCLD) -o $@ $< - install -S 4kw $@ - -look: look.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -lp: lp.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -lpd: lpd.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -ls: ls.c - $(CCLD) -o $@ $< - @install -S 20kw $@ - -lspci: lspci.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -mail: mail.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -man: man.c - $(CCLD) -o $@ $< - @install -S 10kw $@ - -mesg: mesg.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -mkdir: mkdir.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -mkfifo: mkfifo.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -mkfs: mkfs.c - $(CCLD) -o $@ $< - @install -S 25kw $@ - -mknod: mknod.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -mkproto: mkproto.c - $(CCLD) -o $@ $< - @install -S 20kw $@ - -modem: modem.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -mount: mount.c - $(CCLD) -o $@ $< - @install -S 12kw $@ - -mt: mt.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -newroot: newroot.c - $(CCLD) -o $@ $< - @install -S 32kw $@ - -nm: nm.c - $(CCLD) -o $@ $< - @install -S 32kw $@ - -nice: nice.c - $(CCLD) -o $@ $< - @install -S 8kw $@ - -nohup: nohup.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -nonamed: nonamed.c - $(CCLD) -o $@ $< - @install -S 8kw $@ - -od: od.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -passwd: passwd.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -paste: paste.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -ping: ping.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -pr: pr.c - $(CCLD) -o $@ $< - @install -S 16kw $@ - -pr_routes: pr_routes.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -progressbar: progressbar.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -prep: prep.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -printf: printf.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -printroot: printroot.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -proto: proto.c - $(CCLD) -o $@ $< - @install -S 15kw $@ - -pwd: pwd.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -pwdauth: pwdauth.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -ramdisk: ramdisk.c - $(CCLD) -o $@ ramdisk.c - @install -S 4kw $@ - -rarpd: rarpd.c - $(CCLD) -o $@ rarpd.c - @install -S 4kw $@ - -rcp: rcp.c - $(CCLD) -o $@ rcp.c - @install -S 8kw $@ - -rawspeed: rawspeed.c - $(CCLD) -o $@ rawspeed.c - @install -S 512k $@ - -rdate: rdate.c - $(CCLD) -o $@ rdate.c - @install -S 8kw $@ - -rev: rev.c - $(CCLD) -o $@ rev.c - @install -S 8kw $@ - -readall: readall.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -readfs: readfs.c - $(CCLD) -o $@ $< - @install -S 25kw $@ - -remsync: remsync.c - $(CCLD) -o $@ $< - @install -S 256k $@ - -rget: rget.c - $(CCLD) -o $@ $< - @install -S 8kw $@ - -rlogin: rlogin.c - $(CCLD) -o $@ $< - @install -S 8kw $@ - -rmdir: rmdir.c - $(CCLD) -o $@ $< - @install -S 15kw $@ - -rsh: rsh.c - $(CCLD) -o $@ rsh.c - @install -S 8kw $@ - -sed: sed.c - $(CCLD) -o $@ $< - @install -S 8kw $@ - -shar: shar.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -size: size.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -sleep: sleep.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -slip: slip.c - $(CCLD) -o $@ $< - @install -S 20k $@ - -sort: sort.c - $(CCLD) -o $@ $< - @install -S 30kw $@ - -split: split.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -stat: stat.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -strings: strings.c - $(CCLD) -o $@ $< - @install -S 8kw $@ - -strip: strip.c - $(CCLD) -o $@ $< - @install -S 8kw $@ - -stty: stty.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -su: su.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -sum: sum.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -swapfs: swapfs.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -sync: sync.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -synctree: synctree.c - $(CCLD) -o $@ -wo $< - install -S 256kw $@ - -sysenv: sysenv.c - $(CCLD) -o $@ -wo $< - @install -S 4kw $@ - -tail: tail.c - $(CCLD) -o $@ $< - @install -S 16kw $@ - -tcpd: tcpd.c - $(CCLD) -o $@ -DPARANOID=0 tcpd.c - @install -S 8kw $@ - -tcpdp: tcpd.c - $(CCLD) -o $@ -DPARANOID=1 tcpd.c - @install -S 8kw $@ - -tcpstat: tcpstat.c - $(CCLD) -o $@ -I$(SERVERS) tcpstat.c - @install -S 8kw $@ - -tee: tee.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -term: term.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -termcap: termcap.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -tget: tget.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -time: time.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -touch: touch.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -top: top.c - $(CCLD) -o $@ $< -lcurses - -tr: tr.c str.c - $(CCLD) -o $@ tr.c str.c - -tsort: tsort.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -truncate: truncate.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -ttt: ttt.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -tty: tty.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -udpstat: udpstat.c - $(CCLD) -o $@ -I$(SERVERS) $< - @install -S 32k $@ - -umount: umount.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -uname: uname.c /usr/include/minix/config.h - $(CCLD) -o $@ uname.c - @install -S 4kw $@ - -unexpand: unexpand.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -uniq: uniq.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -update: update.c - $(CCLD) -o $@ $< - @install -S 2kw $@ - -uud: uud.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -uue: uue.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -vol: vol.c - $(CCLD) -o $@ $< - @install -S 80k $@ # note: '-S' is upper limit to 'vol -m' - -wc: wc.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -which: which.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -who: who.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -whoami: whoami.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -write: write.c - $(CCLD) -o $@ $< - -writeisofs: writeisofs.c - $(CCLD) -o $@ $< - -xargs: xargs.c - $(CCLD) -o $@ $< - @install -S 16kw $@ - -yes: yes.c - $(CCLD) -o $@ $< - @install -S 4kw $@ - -install: \ - /usr/bin/add_route \ - /usr/bin/del_route \ - /usr/bin/arp \ - /usr/bin/at \ - /usr/bin/backup \ - /usr/bin/restore \ - /usr/bin/rev \ - /usr/bin/badblocks \ - /usr/bin/banner \ - /usr/bin/basename \ - /usr/bin/cal \ - /usr/bin/calendar \ - /usr/bin/cat \ - /usr/bin/cdiff \ - /usr/bin/cdprobe \ - /usr/bin/cgrep \ - /usr/bin/chmem \ - /usr/bin/chmod \ - /usr/bin/chown \ - /bin/chroot \ - /usr/bin/chgrp \ - /usr/bin/ci \ - /usr/bin/cksum \ - /usr/bin/cleantmp \ - /usr/bin/cmp \ - /usr/bin/co \ - /usr/bin/comm \ - /usr/bin/compress \ - /usr/bin/uncompress \ - /usr/bin/zcat \ - /bin/cp \ - /bin/rm \ - /bin/mv \ - /bin/ln \ - /usr/bin/cp \ - /usr/bin/clone \ - /usr/bin/cpdir \ - /usr/bin/ln \ - /usr/bin/mv \ - /usr/bin/rm \ - /bin/rm \ - /usr/bin/crc \ - /usr/bin/cut \ - /usr/bin/dd \ - /usr/bin/decomp16 \ - /bin/dev2name \ - /usr/bin/devsize \ - /usr/bin/df \ - /usr/bin/dhrystone \ - /usr/bin/diff \ - /usr/bin/dirname \ - /usr/bin/du \ - /usr/bin/dumpcore \ - /usr/bin/ed \ - /usr/bin/eject \ - /usr/bin/env \ - /usr/bin/expand \ - /usr/bin/factor \ - /usr/bin/fgrep \ - /usr/bin/file \ - /usr/bin/find \ - /usr/bin/finger \ - /usr/bin/fix \ - /usr/bin/fold \ - /usr/bin/fortune \ - /usr/bin/fsck \ - /usr/bin/fsck1 \ - /bin/getty \ - /usr/bin/getty \ - /usr/bin/gomoku \ - /usr/bin/grep \ - /usr/bin/egrep \ - /usr/bin/head \ - /usr/bin/host \ - /usr/bin/hostaddr \ - /usr/bin/id \ - /usr/bin/ifconfig \ - /usr/bin/ifdef \ - /usr/bin/in.fingerd \ - /usr/bin/in.rshd \ - /bin/install \ - /usr/bin/install \ - /usr/bin/intr \ - /usr/bin/ipcs \ - /usr/bin/ipcrm \ - /usr/bin/irdpd \ - /usr/bin/isoread \ - /usr/bin/isodir \ - /usr/bin/isoinfo \ - /usr/bin/join \ - /usr/bin/kill \ - /usr/bin/leave \ - /usr/bin/last \ - /usr/bin/uptime \ - /usr/bin/life \ - /usr/bin/loadramdisk \ - /usr/bin/login \ - /usr/bin/look \ - /usr/bin/lp \ - /usr/bin/lpd \ - /usr/bin/ls \ - /bin/ls \ - /usr/bin/lspci \ - /usr/bin/mail \ - /usr/bin/man \ - /usr/bin/mesg \ - /usr/bin/mkdir \ - /usr/bin/mkfifo \ - /usr/bin/mkfs \ - /usr/bin/mknod \ - /usr/bin/mkproto \ - /usr/bin/modem \ - /usr/bin/mount \ - /usr/bin/mt \ - /usr/bin/newroot \ - /usr/bin/nm \ - /usr/bin/nice \ - /usr/bin/nohup \ - /usr/bin/nonamed \ - /usr/bin/od \ - /usr/bin/passwd \ - /usr/bin/chfn \ - /usr/bin/chsh \ - /usr/bin/paste \ - /usr/bin/ping \ - /usr/bin/pr \ - /usr/bin/pr_routes \ - /usr/bin/progressbar \ - /usr/bin/prep \ - /usr/bin/printf \ - /usr/bin/printenv \ - /usr/bin/printroot \ - /usr/bin/proto \ - /usr/bin/pwd \ - /usr/lib/pwdauth \ - /usr/bin/ramdisk \ - /usr/bin/rarpd \ - /usr/bin/rcp \ - /usr/bin/rawspeed \ - /usr/bin/rdate \ - /usr/bin/readall \ - /usr/bin/readlink \ - /usr/bin/readfs \ - /usr/bin/remsync \ - /usr/bin/rget \ - /usr/bin/rput \ - /usr/bin/rlogin \ - /usr/bin/rmdir \ - /usr/bin/rsh \ - /usr/bin/sed \ - /bin/sed \ - /usr/bin/shar \ - /usr/bin/size \ - /usr/bin/sleep \ - /usr/bin/slip \ - /usr/bin/sort \ - /usr/bin/split \ - /usr/bin/stat \ - /usr/bin/fstat \ - /usr/bin/strings \ - /usr/bin/strip \ - /usr/bin/stty \ - /usr/bin/su \ - /usr/bin/sum \ - /usr/bin/swapfs \ - /usr/bin/sync \ - /usr/bin/synctree \ - /usr/bin/sysenv \ - /bin/sysenv \ - /usr/bin/tail \ - /usr/bin/tcpd \ - /usr/bin/tcpdp \ - /usr/bin/tcpstat \ - /usr/bin/tee \ - /usr/bin/term \ - /usr/bin/termcap \ - /usr/bin/tget \ - /usr/bin/time \ - /usr/bin/top \ - /usr/bin/touch \ - /usr/bin/tr \ - /usr/bin/truncate \ - /usr/bin/tsort \ - /usr/bin/ttt \ - /usr/bin/tty \ - /usr/bin/udpstat \ - /usr/bin/umount \ - /usr/bin/uname \ - /usr/bin/arch \ - /usr/bin/unexpand \ - /usr/bin/uniq \ - /usr/bin/update \ - /usr/bin/uud \ - /usr/bin/uudecode \ - /usr/bin/uue \ - /usr/bin/uuencode \ - /usr/bin/vol \ - /usr/bin/wc \ - /usr/bin/which \ - /usr/bin/who \ - /usr/bin/whoami \ - /usr/bin/write \ - /usr/bin/writeisofs \ - /usr/bin/xargs \ - /usr/bin/yes \ - /usr/bin/udpstat \ - /bin/cat \ - /bin/fsck \ - /bin/intr \ - /bin/mount \ - /bin/printroot \ - /bin/pwd \ - /bin/sync \ - /bin/umount \ - # - -/usr/bin/add_route: add_route - install -cs -o bin $> $@ - -/usr/bin/del_route: /usr/bin/add_route - install -l h $> $@ - -/usr/bin/arp: arp - install -cs -o root -m 4755 $> $@ - -/usr/bin/at: at - install -cs -o root -m 4755 $> $@ - -/usr/bin/backup: backup - install -cs -o bin $> $@ - -/usr/bin/restore: /usr/bin/backup - install -l h $> $@ - -/usr/bin/badblocks: badblocks - install -cs -o bin $> $@ - -/usr/bin/banner: banner - install -cs -o bin $> $@ - -/usr/bin/basename: basename - install -cs -o bin $> $@ - -/usr/bin/cal: cal - install -cs -o bin $> $@ - -/usr/bin/calendar: calendar - install -cs -o bin $> $@ - -/usr/bin/cat: cat - install -cs -o bin $> $@ - -/usr/bin/cdiff: cdiff - install -cs -o bin $> $@ - -/usr/bin/cdprobe: cdprobe - install -cs -o bin $> $@ - -/usr/bin/cgrep: cgrep - install -cs -o bin $> $@ - -/usr/bin/chmem: chmem - install -cs -o bin $> $@ - -/usr/bin/chmod: chmod - install -cs -o bin $> $@ - -/usr/bin/chown: chown - install -cs -o bin $> $@ - -/bin/chroot: chroot - install -cs -o bin $> $@ - -/usr/bin/chgrp: /usr/bin/chown - install -l h $> $@ - -/usr/bin/ci: ci - install -cs -o bin $> $@ - -/usr/bin/cksum: cksum - install -cs -o bin $> $@ - -/usr/bin/cleantmp: cleantmp - install -cs -o bin $> $@ - -/usr/bin/cmp: cmp - install -cs -o bin $> $@ - -/usr/bin/co: co - install -cs -o bin $> $@ - -/usr/bin/comm: comm - install -cs -o bin $> $@ - -/usr/bin/compress: compress - install -cs -o bin $> $@ - -/usr/bin/uncompress /usr/bin/zcat: /usr/bin/compress - install -l h $> $@ - -/bin/cp: cp - install -cs -o bin $> $@ - -/usr/bin/cp: cp - install -cs -o bin $> $@ - -/usr/bin/clone /usr/bin/cpdir \ -/usr/bin/ln /usr/bin/mv /usr/bin/rm: /usr/bin/cp - install -l h $> $@ - -/bin/ln /bin/mv /bin/rm: /bin/cp - install -l h $> $@ - -/usr/bin/crc: crc - install -cs -o bin $> $@ - -/usr/bin/cut: cut - install -cs -o bin $> $@ - -/usr/bin/dd: dd - install -cs -o bin $> $@ - -/bin/dev2name: dev2name - install -cs -o bin $> $@ - -/usr/bin/devsize: devsize - install -cs -o bin $> $@ - -/usr/bin/decomp16: decomp16 - install -cs -o bin $> $@ - -/usr/bin/df: df - install -cs -o root -m 4755 $> $@ - -/usr/bin/dhrystone: dhrystone - install -cs -o bin $> $@ - -/usr/bin/diff: diff - install -cs -o bin $> $@ - -/usr/bin/dirname: dirname - install -cs -o bin $> $@ - -/usr/bin/du: du - install -cs -o bin $> $@ - -/usr/bin/dumpcore: dumpcore - install -cs -o bin $> $@ - -/usr/bin/ed: ed - install -cs -o bin $> $@ - -/usr/bin/eject: eject - install -cs -o bin $> $@ - -/usr/bin/env: env - install -cs -o bin $> $@ - -/usr/bin/expand: expand - install -cs -o bin $> $@ - -/usr/bin/factor: factor - install -cs -o bin $> $@ - -/usr/bin/fgrep: fgrep - install -cs -o bin $> $@ - -/usr/bin/file: file - install -cs -o bin $> $@ - -/usr/bin/find: find - install -cs -o bin $> $@ - -/usr/bin/finger: finger - install -cs -o bin $> $@ - -/usr/bin/fix: fix - install -cs -o bin $> $@ - -/usr/bin/fold: fold - install -cs -o bin $> $@ - -/usr/bin/fortune: fortune - install -cs -o bin $> $@ - -/usr/bin/fsck: fsck - install -cs -o bin $> $@ - -/usr/bin/fsck1: fsck1 - install -cs -o bin $> $@ - -/bin/getty: getty - install -cs -o bin $> $@ - -/usr/bin/getty: getty - install -cs -o bin $> $@ - -/usr/bin/gomoku: gomoku - install -cs -o bin $> $@ - -/usr/bin/grep: grep - install -cs -o bin $> $@ - -/usr/bin/egrep: /usr/bin/grep - install -l h $> $@ - -/usr/bin/head: head - install -cs -o bin $> $@ - -/usr/bin/host: host - install -cs -o bin $> $@ - -/usr/bin/hostaddr: hostaddr - install -cs -o root -m 4755 $> $@ - -/usr/bin/id: id - install -cs -o bin $> $@ - -/usr/bin/ifconfig: ifconfig - install -cs -o root -m 4755 $> $@ - -/usr/bin/ifdef: ifdef - install -cs -o bin $> $@ - -/usr/bin/in.fingerd: in.fingerd - install -cs -o bin $> $@ - -/usr/bin/in.rshd: in.rshd - install -cs -o bin $> $@ - -/bin/install: installx - install -cs -o root -m 4755 $> $@ - -/usr/bin/install: installx - install -cs -o root -m 4755 $> $@ - -/usr/bin/intr: intr - install -cs -o bin $> $@ - -/usr/bin/ipcs: ipcs - install -cs -o bin $> $@ - -/usr/bin/ipcrm: ipcrm - install -cs -o bin $> $@ - -/usr/bin/irdpd: irdpd - install -cs -o bin $> $@ - -/usr/bin/isoread: isoread - install -cs -o bin $> $@ - -/usr/bin/isodir /usr/bin/isoinfo: /usr/bin/isoread - install -l h $> $@ - -/usr/bin/join: join - install -cs -o bin $> $@ - -/usr/bin/kill: kill - install -cs -o bin $> $@ - -/usr/bin/last: last - install -cs -o bin $> $@ - -/usr/bin/uptime: /usr/bin/last - install -l h $> $@ - -/usr/bin/leave: leave - install -cs -o bin $> $@ - -/usr/bin/life: life - install -cs -o bin $> $@ - -/usr/bin/loadramdisk: loadramdisk - install -cs -o bin $> $@ - -/usr/bin/login: login - install -cs -o bin $> $@ - -/usr/bin/look: look - install -cs -o bin $> $@ - -/usr/bin/lp: lp - install -cs -o bin $> $@ - -/usr/bin/lpd: lpd - install -cs -o daemon -m 4755 $> $@ - -/usr/bin/ls: ls - install -cs -o bin $> $@ - -/bin/ls: ls - install -cs -o bin $> $@ - -/usr/bin/lspci: lspci - install -cs -o bin $> $@ - -/usr/bin/mail: mail - install -cs -o root -m 4755 $> $@ - -/usr/bin/man: man - install -cs -o bin $> $@ - -/usr/bin/mesg: mesg - install -cs -o bin $> $@ - -/usr/bin/mkdir: mkdir - install -cs -o bin $> $@ - -/usr/bin/mkfifo: mkfifo - install -cs -o bin $> $@ - -/usr/bin/mkfs: mkfs - install -cs -o bin $> $@ - -/usr/bin/mknod: mknod - install -cs -o bin $> $@ - -/usr/bin/mkproto: mkproto - install -cs -o bin $> $@ - -/usr/bin/modem: modem - install -cs -o bin $> $@ - -/usr/bin/mount: mount - install -cs -o root -m 4755 $> $@ - -/usr/bin/mt: mt - install -cs -o bin $> $@ - -/usr/bin/newroot: newroot - install -cs -o bin $> $@ - -/usr/bin/nm: nm - install -cs -o bin $> $@ - -/usr/bin/nice: nice - install -cs -o bin $> $@ - -/usr/bin/nohup: nohup - install -cs -o bin $> $@ - -/usr/bin/nonamed: nonamed - install -cs -o bin $> $@ - -/usr/bin/od: od - install -cs -o bin $> $@ - -/usr/bin/passwd: passwd - install -cs -o root -m 4755 $> $@ - -/usr/bin/chfn /usr/bin/chsh: /usr/bin/passwd - install -l h $> $@ - -/usr/bin/paste: paste - install -cs -o bin $> $@ - -/usr/bin/ping: ping - install -cs -o root -m 4755 $> $@ - -/usr/bin/pr: pr - install -cs -o bin $> $@ - -/usr/bin/pr_routes: pr_routes - install -cs -o root -m 4755 $> $@ - -/usr/bin/progressbar: progressbar - install -cs -o root -m 755 $> $@ - -/usr/bin/prep: prep - install -cs -o bin $> $@ - -/usr/bin/printf: printf - install -cs -o bin $> $@ - -/usr/bin/printenv: /usr/bin/env - install -l h -s -o bin /usr/bin/env /usr/bin/printenv - -/usr/bin/printroot: printroot - install -cs -o bin $> $@ - -/usr/bin/proto: proto - install -cs -o bin $> $@ - -/usr/bin/pwd: pwd - install -cs -o bin $> $@ - -/usr/lib/pwdauth: pwdauth - install -cs -o root -m 4755 $> $@ - -/usr/bin/ramdisk: ramdisk - install -cs -o bin $> $@ - -/usr/bin/rarpd: rarpd - install -cs -o bin $> $@ - -/usr/bin/rcp: rcp - install -cs -o bin $> $@ - -/usr/bin/rawspeed: rawspeed - install -cs -o bin $> $@ - -/usr/bin/rdate: rdate - install -cs -o bin $> $@ - -/usr/bin/readall: readall - install -cs -o bin $> $@ - -/usr/bin/readlink: /usr/bin/stat - install -l h $> $@ - -/usr/bin/readfs: readfs - install -cs -o bin $> $@ - -/usr/bin/remsync: remsync - install -cs -o bin $> $@ - -/usr/bin/rev: rev - install -cs -o bin $> $@ - -/usr/bin/rget: rget - install -cs -o bin $> $@ - -/usr/bin/rput: /usr/bin/rget - install -l h $> $@ - -/usr/bin/rlogin: rlogin - install -cs -o bin $> $@ - -/usr/bin/rmdir: rmdir - install -cs -o bin $> $@ - -/usr/bin/rsh: rsh - install -cs -o bin $> $@ - -/usr/bin/sed: sed - install -cs -o bin $> $@ - -/bin/sed: sed - install -cs -o bin $> $@ - -/usr/bin/shar: shar - install -cs -o bin $> $@ - -/usr/bin/size: size - install -cs -o bin $> $@ - -/usr/bin/sleep: sleep - install -cs -o bin $> $@ - -/usr/bin/slip: slip - install -cs -o bin $> $@ - -/usr/bin/sort: sort - install -cs -o bin $> $@ - -/usr/bin/split: split - install -cs -o bin $> $@ - -/usr/bin/stat: stat - install -cs -o bin $> $@ - -/usr/bin/fstat: /usr/bin/stat - install -l h $> $@ - -/usr/bin/strings: strings - install -cs -o bin $> $@ - -/usr/bin/strip: strip - install -cs -o bin $> $@ - -/usr/bin/stty: stty - install -cs -o bin $> $@ - -/usr/bin/su: su - install -cs -o root -m 4755 $> $@ - -/usr/bin/sum: sum - install -cs -o bin $> $@ - -/usr/bin/swapfs: swapfs - install -cs -o bin $> $@ - -/usr/bin/sync: sync - install -cs -o bin $> $@ - -/usr/bin/synctree: synctree - install -cs -o bin $> $@ - -/bin/sysenv: sysenv - install -cs -o bin $> $@ - -/usr/bin/sysenv: sysenv - install -cs -o bin $> $@ - -/usr/bin/tail: tail - install -cs -o bin $> $@ - -/usr/bin/tcpd: tcpd - install -cs -o bin $> $@ - -/usr/bin/tcpdp: tcpdp - install -cs -o bin $> $@ - -/usr/bin/tcpstat: tcpstat - install -cs -o bin $> $@ - -/usr/bin/tee: tee - install -cs -o bin $> $@ - -/usr/bin/term: term - install -cs -o bin -g uucp -m 2755 $> $@ - -/usr/bin/termcap: termcap - install -cs -o bin $> $@ - -/usr/bin/tget: tget - install -cs -o bin $> $@ - -/usr/bin/time: time - install -cs -o bin $> $@ - -/usr/bin/top: top - install -cs -o root -m 4755 $> $@ - -/usr/bin/touch: touch - install -cs -o bin $> $@ - -/usr/bin/tr: tr - install -cs -o bin $> $@ - -/usr/bin/truncate: truncate - install -cs -o bin $> $@ - -/usr/bin/tsort: tsort - install -cs -o bin $> $@ - -/usr/bin/ttt: ttt - install -cs -o bin $> $@ - -/usr/bin/tty: tty - install -cs -o bin $> $@ - -/usr/bin/udpstat: udpstat - install -cs -o bin $> $@ - -/usr/bin/umount: umount - install -cs -o root -m 4755 $> $@ - -/usr/bin/uname: uname - install -cs -o bin $> $@ - -/usr/bin/arch: /usr/bin/uname - install -l h $> $@ - -/usr/bin/unexpand: unexpand - install -cs -o bin $> $@ - -/usr/bin/uniq: uniq - install -cs -o bin $> $@ - -/usr/bin/update: update - install -cs -o bin $> $@ - -/usr/bin/uud: uud - install -cs -o bin $> $@ - -/usr/bin/uudecode: /usr/bin/uud - install -l h $> $@ - -/usr/bin/uue: uue - install -cs -o bin $> $@ - -/usr/bin/uuencode: /usr/bin/uue - install -l h $> $@ - -/usr/bin/vol: vol - install -cs -o bin $> $@ - -/usr/bin/wc: wc - install -cs -o bin $> $@ - -/usr/bin/which: which - install -cs -o bin $> $@ - -/usr/bin/who: who - install -cs -o bin $> $@ - -/usr/bin/whoami: whoami - install -cs -o bin $> $@ - -/usr/bin/write: write - install -cs -o bin -g tty -m 2755 $> $@ - -/usr/bin/writeisofs: writeisofs - install -cs -S 2M -o bin $> $@ - -/usr/bin/xargs: xargs - install -cs -o bin $> $@ - -/usr/bin/yes: yes - install -cs -o bin $> $@ - -/bin/cat: /usr/bin/cat - install -l h -cs $> $@ - -/bin/fsck: /usr/bin/fsck - install -l h -cs $> $@ - -/bin/intr: /usr/bin/intr - install -l h -cs $> $@ - -/bin/mount: /usr/bin/mount - install -l h -cs $> $@ - -/bin/printroot: /usr/bin/printroot - install -l h -cs $> $@ - -/bin/pwd: /usr/bin/pwd - install -l h -cs $> $@ - -/bin/sync: /usr/bin/sync - install -l h -cs $> $@ - -/bin/umount: /usr/bin/umount - install -l h -cs $> $@ - -clean: - rm -rf $(ALL) a.out core - diff --git a/commands/simple/build b/commands/simple/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/simple/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/simple/origmkfs.c b/commands/simple/origmkfs.c deleted file mode 100644 index 7d70f7443..000000000 --- a/commands/simple/origmkfs.c +++ /dev/null @@ -1,1341 +0,0 @@ -/* mkfs - make the MINIX filesystem Authors: Tanenbaum et al. */ - -/* Authors: Andy Tanenbaum, Paul Ogilvie, Frans Meulenbroeks, Bruce Evans - * - * This program can make both version 1 and version 2 file systems, as follows: - * mkfs /dev/fd0 1200 # Version 2 (default) - * mkfs -1 /dev/fd0 360 # Version 1 - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../../servers/fs/const.h" -#if (MACHINE == IBM_PC) -#include -#include -#include -#endif - -#undef EXTERN -#define EXTERN /* get rid of EXTERN by making it null */ -#include "../../servers/fs/type.h" -#include "../../servers/fs/super.h" -#include - -#ifndef DOS -#ifndef UNIX -#define UNIX -#endif -#endif - -#undef BLOCK_SIZE -#define BLOCK_SIZE 1024 - -#define INODE_MAP 2 -#define MAX_TOKENS 10 -#define LINE_LEN 200 -#define BIN 2 -#define BINGRP 2 -#define BIT_MAP_SHIFT 13 -#define N_BLOCKS (1024L * 1024) -#define N_BLOCKS16 (128L * 1024) -#define INODE_MAX ((unsigned) 65535) - -/* You can make a really large file system on a 16-bit system, but the array - * of bits that get_block()/putblock() needs gets a bit big, so we can only - * prefill MAX_INIT blocks. (16-bit fsck can't check a file system larger - * than N_BLOCKS16 anyway.) - */ -#define MAX_INIT (sizeof(char *) == 2 ? N_BLOCKS16 : N_BLOCKS) - - -#ifdef DOS -maybedefine O_RDONLY 4 /* O_RDONLY | BINARY_BIT */ - maybedefine BWRITE 5 /* O_WRONLY | BINARY_BIT */ -#endif - -extern char *optarg; -extern int optind; - -int next_zone, next_inode, zone_size, zone_shift = 0, zoff; -block_t nrblocks; -int inode_offset, lct = 0, disk, fd, print = 0, file = 0; -unsigned int nrinodes; -int override = 0, simple = 0, dflag; -int donttest; /* skip test if it fits on medium */ -char *progname; - -long current_time, bin_time; -char zero[BLOCK_SIZE], *lastp; -char umap[MAX_INIT / 8]; /* bit map tells if block read yet */ -block_t zone_map; /* where is zone map? (depends on # inodes) */ -int inodes_per_block; -int fs_version; -block_t max_nrblocks; - -FILE *proto; - -_PROTOTYPE(int main, (int argc, char **argv)); -_PROTOTYPE(block_t sizeup, (char *device)); -_PROTOTYPE(void super, (zone_t zones, Ino_t inodes)); -_PROTOTYPE(void rootdir, (Ino_t inode)); -_PROTOTYPE(void eat_dir, (Ino_t parent)); -_PROTOTYPE(void eat_file, (Ino_t inode, int f)); -_PROTOTYPE(void enter_dir, (Ino_t parent, char *name, Ino_t child)); -_PROTOTYPE(void incr_size, (Ino_t n, long count)); -_PROTOTYPE(PRIVATE ino_t alloc_inode, (int mode, int usrid, int grpid)); -_PROTOTYPE(PRIVATE zone_t alloc_zone, (void)); -_PROTOTYPE(void add_zone, (Ino_t n, zone_t z, long bytes, long cur_time)); -_PROTOTYPE(void add_z_1, (Ino_t n, zone_t z, long bytes, long cur_time)); -_PROTOTYPE(void add_z_2, (Ino_t n, zone_t z, long bytes, long cur_time)); -_PROTOTYPE(void incr_link, (Ino_t n)); -_PROTOTYPE(void insert_bit, (block_t block, int bit)); -_PROTOTYPE(int mode_con, (char *p)); -_PROTOTYPE(void getline, (char line[LINE_LEN], char *parse[MAX_TOKENS])); -_PROTOTYPE(void check_mtab, (char *devname)); -_PROTOTYPE(long file_time, (int f)); -_PROTOTYPE(void pexit, (char *s)); -_PROTOTYPE(void copy, (char *from, char *to, int count)); -_PROTOTYPE(void print_fs, (void)); -_PROTOTYPE(int read_and_set, (block_t n)); -_PROTOTYPE(void special, (char *string)); -_PROTOTYPE(void get_block, (block_t n, char buf[BLOCK_SIZE])); -_PROTOTYPE(void put_block, (block_t n, char buf[BLOCK_SIZE])); -_PROTOTYPE(void cache_init, (void)); -_PROTOTYPE(void flush, (void)); -_PROTOTYPE(void mx_read, (int blocknr, char buf[BLOCK_SIZE])); -_PROTOTYPE(void mx_write, (int blocknr, char buf[BLOCK_SIZE])); -_PROTOTYPE(void dexit, (char *s, int sectnum, int err)); -_PROTOTYPE(void usage, (void)); - -/*================================================================ - * mkfs - make filesystem - *===============================================================*/ -int main(argc, argv) -int argc; -char *argv[]; -{ - int nread, mode, usrid, grpid, ch; - block_t blocks; - block_t i; - ino_t root_inum; - ino_t inodes; - zone_t zones; - char *token[MAX_TOKENS], line[LINE_LEN]; - struct stat statbuf; - - /* Get two times, the current time and the mod time of the binary of - * mkfs itself. When the -d flag is used, the later time is put into - * the i_mtimes of all the files. This feature is useful when - * producing a set of file systems, and one wants all the times to be - * identical. First you set the time of the mkfs binary to what you - * want, then go. - */ - current_time = time((time_t *) 0); /* time mkfs is being run */ - stat(argv[0], &statbuf); - bin_time = statbuf.st_mtime; /* time when mkfs binary was last modified */ - - /* Process switches. */ - progname = argv[0]; - blocks = 0; - i = 0; - fs_version = 2; - inodes_per_block = V2_INODES_PER_BLOCK(BLOCK_SIZE); - max_nrblocks = N_BLOCKS; - while ((ch = getopt(argc, argv, "1b:di:lot")) != EOF) - switch (ch) { - case '1': - fs_version = 1; - inodes_per_block = V1_INODES_PER_BLOCK; - max_nrblocks = 0xFFFF; - break; - case 'b': - blocks = strtoul(optarg, (char **) NULL, 0); - break; - case 'd': - dflag = 1; - current_time = bin_time; - break; - case 'i': - i = strtoul(optarg, (char **) NULL, 0); - break; - case 'l': print = 1; break; - case 'o': override = 1; break; - case 't': donttest = 1; break; - default: usage(); - } - - /* Determine the size of the device if not specified as -b or proto. */ - if (argc - optind == 1 && blocks == 0) blocks = sizeup(argv[optind]); - printf("%lu blocks\n", blocks); - - /* The remaining args must be 'special proto', or just 'special' if the - * block size has already been specified. - */ - if (argc - optind != 2 && (argc - optind != 1 || blocks == 0)) usage(); - - /* Check special. */ - check_mtab(argv[optind]); - - /* Check and start processing proto. */ - optarg = argv[++optind]; - if (optind < argc && (proto = fopen(optarg, "r")) != NULL) { - /* Prototype file is readable. */ - lct = 1; - getline(line, token); /* skip boot block info */ - - /* Read the line with the block and inode counts. */ - getline(line, token); - blocks = atol(token[0]); - if (blocks > max_nrblocks) { - printf("%d > %d\n", blocks, max_nrblocks); - pexit("Block count too large"); - } - if (sizeof(char *) == 2 && blocks > N_BLOCKS16) { - fprintf(stderr, - "%s: warning: FS is larger than the %dM that fsck can check!\n", - progname, (int) (N_BLOCKS16 / (1024L * 1024))); - } - inodes = atoi(token[1]); - - /* Process mode line for root directory. */ - getline(line, token); - mode = mode_con(token[0]); - usrid = atoi(token[1]); - grpid = atoi(token[2]); - } else { - lct = 0; - if (optind < argc) { - /* Maybe the prototype file is just a size. Check. */ - blocks = strtoul(optarg, (char **) NULL, 0); - if (blocks == 0) pexit("Can't open prototype file"); - } - if (i == 0) { - /* The default for inodes is 3 blocks per inode, rounded up - * to fill an inode block. Above 20M, the average files are - * sure to be larger because it is hard to fill up 20M with - * tiny files, so reduce the default number of inodes. This - * default can always be overridden by using the -i option. - */ - i = blocks / 3; - if (blocks >= 20000) i = blocks / 4; - if (blocks >= 40000) i = blocks / 5; - if (blocks >= 60000) i = blocks / 6; - if (blocks >= 80000) i = blocks / 7; - if (blocks >= 100000) i = blocks / 8; - i += inodes_per_block - 1; - i = i / inodes_per_block * inodes_per_block; - if (i > INODE_MAX) i = INODE_MAX; - } - if (blocks < 5) pexit("Block count too small"); - if (blocks > max_nrblocks) { - printf("%d > %d\n", blocks, max_nrblocks); - pexit("Block count too large"); - } - if (i < 1) pexit("Inode count too small"); - if (i > INODE_MAX) pexit("Inode count too large"); - inodes = (ino_t) i; - - /* Make simple file system of the given size, using defaults. */ - mode = 040777; - usrid = BIN; - grpid = BINGRP; - simple = 1; - } - nrblocks = blocks; - nrinodes = inodes; - - /* Open special. */ - special(argv[--optind]); - -#ifdef UNIX - if (!donttest) { - static short testb[BLOCK_SIZE / sizeof(short)]; - - /* Try writing the last block of partition or diskette. */ - lseek(fd, (off_t) (blocks - 1) * BLOCK_SIZE, SEEK_SET); - testb[0] = 0x3245; - testb[1] = 0x11FF; - if (write(fd, (char *) testb, BLOCK_SIZE) != BLOCK_SIZE) - pexit("File system is too big for minor device"); - sync(); /* flush write, so if error next read fails */ - lseek(fd, (off_t) (blocks - 1) * BLOCK_SIZE, SEEK_SET); - testb[0] = 0; - testb[1] = 0; - nread = read(fd, (char *) testb, BLOCK_SIZE); - if (nread != BLOCK_SIZE || testb[0] != 0x3245 || testb[1] != 0x11FF) - pexit("File system is too big for minor device"); - lseek(fd, (off_t) (blocks - 1) * BLOCK_SIZE, SEEK_SET); - testb[0] = 0; - testb[1] = 0; - if (write(fd, (char *) testb, BLOCK_SIZE) != BLOCK_SIZE) - pexit("File system is too big for minor device"); - lseek(fd, 0L, SEEK_SET); - } -#endif - - /* Make the file-system */ - - cache_init(); - - put_block((block_t) 0, zero); /* Write a null boot block. */ - - zone_shift = 0; /* for future use */ - zones = nrblocks >> zone_shift; - - super(zones, inodes); - - root_inum = alloc_inode(mode, usrid, grpid); - rootdir(root_inum); - if (simple == 0) eat_dir(root_inum); - - if (print) print_fs(); - flush(); - return(0); - - /* NOTREACHED */ -} /* end main */ - - -/*================================================================ - * sizeup - determine device size - *===============================================================*/ -block_t sizeup(device) -char *device; -{ - int fd; - struct partition entry; - - if ((fd = open(device, O_RDONLY)) == -1) return 0; - if (ioctl(fd, DIOCGETP, &entry) == -1) entry.size = cvu64(0); - close(fd); - return div64u(entry.size, BLOCK_SIZE); -} - - -/*================================================================ - * super - construct a superblock - *===============================================================*/ - -void super(zones, inodes) -zone_t zones; -ino_t inodes; -{ - unsigned int i; - int inodeblks; - int initblks; - - zone_t initzones, nrzones, v1sq, v2sq; - zone_t zo; - struct super_block *sup; - char buf[BLOCK_SIZE], *cp; - - for (cp = buf; cp < &buf[BLOCK_SIZE]; cp++) *cp = 0; - sup = (struct super_block *) buf; /* lint - might use a union */ - - sup->s_ninodes = inodes; - if (fs_version == 1) { - sup->s_nzones = zones; - } else { - sup->s_nzones = 0; /* not used in V2 - 0 forces errors early */ - sup->s_zones = zones; - } - sup->s_imap_blocks = bitmapsize((bit_t) (1 + inodes), BLOCK_SIZE); - sup->s_zmap_blocks = bitmapsize((bit_t) zones, BLOCK_SIZE); - inode_offset = sup->s_imap_blocks + sup->s_zmap_blocks + 2; - inodeblks = (inodes + inodes_per_block - 1) / inodes_per_block; - initblks = inode_offset + inodeblks; - initzones = (initblks + (1 << zone_shift) - 1) >> zone_shift; - nrzones = nrblocks >> zone_shift; - sup->s_firstdatazone = (initblks + (1 << zone_shift) - 1) >> zone_shift; - zoff = sup->s_firstdatazone - 1; - sup->s_log_zone_size = zone_shift; - if (fs_version == 1) { - sup->s_magic = SUPER_MAGIC; /* identify super blocks */ - v1sq = (zone_t) V1_INDIRECTS * V1_INDIRECTS; - zo = V1_NR_DZONES + (long) V1_INDIRECTS + v1sq; - } else { - sup->s_magic = SUPER_V2;/* identify super blocks */ - v2sq = (zone_t) V2_INDIRECTS(BLOCK_SIZE) * V2_INDIRECTS(BLOCK_SIZE); - zo = V2_NR_DZONES + (zone_t) V2_INDIRECTS(BLOCK_SIZE) + v2sq; - } - sup->s_max_size = zo * BLOCK_SIZE; - zone_size = 1 << zone_shift; /* nr of blocks per zone */ - - put_block((block_t) 1, buf); - - /* Clear maps and inodes. */ - for (i = 2; i < initblks; i++) put_block((block_t) i, zero); - - next_zone = sup->s_firstdatazone; - next_inode = 1; - - zone_map = INODE_MAP + sup->s_imap_blocks; - - insert_bit(zone_map, 0); /* bit zero must always be allocated */ - insert_bit((block_t) INODE_MAP, 0); /* inode zero not used but - * must be allocated */ -} - - -/*================================================================ - * rootdir - install the root directory - *===============================================================*/ -void rootdir(inode) -ino_t inode; -{ - zone_t z; - - z = alloc_zone(); - add_zone(inode, z, 32L, current_time); - enter_dir(inode, ".", inode); - enter_dir(inode, "..", inode); - incr_link(inode); - incr_link(inode); -} - - -/*================================================================ - * eat_dir - recursively install directory - *===============================================================*/ -void eat_dir(parent) -ino_t parent; -{ - /* Read prototype lines and set up directory. Recurse if need be. */ - char *token[MAX_TOKENS], *p; - char line[LINE_LEN]; - int mode, usrid, grpid, maj, min, f; - ino_t n; - zone_t z; - long size; - - while (1) { - getline(line, token); - p = token[0]; - if (*p == '$') return; - p = token[1]; - mode = mode_con(p); - usrid = atoi(token[2]); - grpid = atoi(token[3]); - if (grpid & 0200) fprintf(stderr, "A.S.Tanenbaum\n"); - n = alloc_inode(mode, usrid, grpid); - - /* Enter name in directory and update directory's size. */ - enter_dir(parent, token[0], n); - incr_size(parent, 16L); - - /* Check to see if file is directory or special. */ - incr_link(n); - if (*p == 'd') { - /* This is a directory. */ - z = alloc_zone(); /* zone for new directory */ - add_zone(n, z, 32L, current_time); - enter_dir(n, ".", n); - enter_dir(n, "..", parent); - incr_link(parent); - incr_link(n); - eat_dir(n); - } else if (*p == 'b' || *p == 'c') { - /* Special file. */ - maj = atoi(token[4]); - min = atoi(token[5]); - size = 0; - if (token[6]) size = atoi(token[6]); - size = BLOCK_SIZE * size; - add_zone(n, (zone_t) ((maj << 8) | min), size, current_time); - } else { - /* Regular file. Go read it. */ - if ((f = open(token[4], O_RDONLY)) < 0) { - fprintf(stderr, "%s: Can't open %s: %s\n", - progname, token[4], strerror(errno)); - } else - eat_file(n, f); - } - } - -} - -/*================================================================ - * eat_file - copy file to MINIX - *===============================================================*/ -/* Zonesize >= blocksize */ -void eat_file(inode, f) -ino_t inode; -int f; -{ - int ct, i, j, k; - zone_t z; - char buf[BLOCK_SIZE]; - long timeval; - - do { - for (i = 0, j = 0; i < zone_size; i++, j += ct) { - for (k = 0; k < BLOCK_SIZE; k++) buf[k] = 0; - if ((ct = read(f, buf, BLOCK_SIZE)) > 0) { - if (i == 0) z = alloc_zone(); - put_block((z << zone_shift) + i, buf); - } - } - timeval = (dflag ? current_time : file_time(f)); - if (ct) add_zone(inode, z, (long) j, timeval); - } while (ct == BLOCK_SIZE); - close(f); -} - - - -/*================================================================ - * directory & inode management assist group - *===============================================================*/ -void enter_dir(parent, name, child) -ino_t parent, child; -char *name; -{ - /* Enter child in parent directory */ - /* Works for dir > 1 block and zone > block */ - int i, j, k, l, off; - block_t b; - zone_t z; - char *p1, *p2; - struct direct dir_entry[NR_DIR_ENTRIES(BLOCK_SIZE)]; - d1_inode ino1[V1_INODES_PER_BLOCK]; - d2_inode ino2[V2_INODES_PER_BLOCK(BLOCK_SIZE)]; - int nr_dzones; - - b = ((parent - 1) / inodes_per_block) + inode_offset; - off = (parent - 1) % inodes_per_block; - - if (fs_version == 1) { - get_block(b, (char *) ino1); - nr_dzones = V1_NR_DZONES; - } else { - get_block(b, (char *) ino2); - nr_dzones = V2_NR_DZONES; - } - for (k = 0; k < nr_dzones; k++) { - if (fs_version == 1) { - z = ino1[off].d1_zone[k]; - if (z == 0) { - z = alloc_zone(); - ino1[off].d1_zone[k] = z; - } - } else { - z = ino2[off].d2_zone[k]; - if (z == 0) { - z = alloc_zone(); - ino2[off].d2_zone[k] = z; - } - } - for (l = 0; l < zone_size; l++) { - get_block((z << zone_shift) + l, (char *) dir_entry); - for (i = 0; i < NR_DIR_ENTRIES(BLOCK_SIZE); i++) { - if (dir_entry[i].d_ino == 0) { - dir_entry[i].d_ino = child; - p1 = name; - p2 = dir_entry[i].d_name; - j = 14; - while (j--) { - *p2++ = *p1; - if (*p1 != 0) p1++; - } - put_block((z << zone_shift) + l, (char *) dir_entry); - if (fs_version == 1) { - put_block(b, (char *) ino1); - } else { - put_block(b, (char *) ino2); - } - return; - } - } - } - } - - printf("Directory-inode %d beyond direct blocks. Could not enter %s\n", - parent, name); - pexit("Halt"); -} - - -void add_zone(n, z, bytes, cur_time) -ino_t n; -zone_t z; -long bytes, cur_time; -{ - if (fs_version == 1) { - add_z_1(n, z, bytes, cur_time); - } else { - add_z_2(n, z, bytes, cur_time); - } -} - -void add_z_1(n, z, bytes, cur_time) -ino_t n; -zone_t z; -long bytes, cur_time; -{ - /* Add zone z to inode n. The file has grown by 'bytes' bytes. */ - - int off, i; - block_t b; - zone_t indir; - zone1_t blk[V1_INDIRECTS]; - d1_inode *p; - d1_inode inode[V1_INODES_PER_BLOCK]; - - b = ((n - 1) / V1_INODES_PER_BLOCK) + inode_offset; - off = (n - 1) % V1_INODES_PER_BLOCK; - get_block(b, (char *) inode); - p = &inode[off]; - p->d1_size += bytes; - p->d1_mtime = cur_time; - for (i = 0; i < V1_NR_DZONES; i++) - if (p->d1_zone[i] == 0) { - p->d1_zone[i] = (zone1_t) z; - put_block(b, (char *) inode); - return; - } - put_block(b, (char *) inode); - - /* File has grown beyond a small file. */ - if (p->d1_zone[V1_NR_DZONES] == 0) - p->d1_zone[V1_NR_DZONES] = (zone1_t) alloc_zone(); - indir = p->d1_zone[V1_NR_DZONES]; - put_block(b, (char *) inode); - b = indir << zone_shift; - get_block(b, (char *) blk); - for (i = 0; i < V1_INDIRECTS; i++) - if (blk[i] == 0) { - blk[i] = (zone1_t) z; - put_block(b, (char *) blk); - return; - } - pexit("File has grown beyond single indirect"); -} - -void add_z_2(n, z, bytes, cur_time) -ino_t n; -zone_t z; -long bytes, cur_time; -{ - /* Add zone z to inode n. The file has grown by 'bytes' bytes. */ - - int off, i; - block_t b; - zone_t indir; - zone_t blk[V2_INDIRECTS(BLOCK_SIZE)]; - d2_inode *p; - d2_inode inode[V2_INODES_PER_BLOCK(BLOCK_SIZE)]; - - b = ((n - 1) / V2_INODES_PER_BLOCK(BLOCK_SIZE)) + inode_offset; - off = (n - 1) % V2_INODES_PER_BLOCK(BLOCK_SIZE); - get_block(b, (char *) inode); - p = &inode[off]; - p->d2_size += bytes; - p->d2_mtime = cur_time; - for (i = 0; i < V2_NR_DZONES; i++) - if (p->d2_zone[i] == 0) { - p->d2_zone[i] = z; - put_block(b, (char *) inode); - return; - } - put_block(b, (char *) inode); - - /* File has grown beyond a small file. */ - if (p->d2_zone[V2_NR_DZONES] == 0) p->d2_zone[V2_NR_DZONES] = alloc_zone(); - indir = p->d2_zone[V2_NR_DZONES]; - put_block(b, (char *) inode); - b = indir << zone_shift; - get_block(b, (char *) blk); - for (i = 0; i < V2_INDIRECTS(BLOCK_SIZE); i++) - if (blk[i] == 0) { - blk[i] = z; - put_block(b, (char *) blk); - return; - } - pexit("File has grown beyond single indirect"); -} - - -void incr_link(n) -ino_t n; -{ - /* Increment the link count to inode n */ - int off; - block_t b; - - b = ((n - 1) / inodes_per_block) + inode_offset; - off = (n - 1) % inodes_per_block; - if (fs_version == 1) { - d1_inode inode1[V1_INODES_PER_BLOCK]; - - get_block(b, (char *) inode1); - inode1[off].d1_nlinks++; - put_block(b, (char *) inode1); - } else { - d2_inode inode2[V2_INODES_PER_BLOCK(BLOCK_SIZE)]; - - get_block(b, (char *) inode2); - inode2[off].d2_nlinks++; - put_block(b, (char *) inode2); - } -} - - -void incr_size(n, count) -ino_t n; -long count; -{ - /* Increment the file-size in inode n */ - block_t b; - int off; - - b = ((n - 1) / inodes_per_block) + inode_offset; - off = (n - 1) % inodes_per_block; - if (fs_version == 1) { - d1_inode inode1[V1_INODES_PER_BLOCK]; - - get_block(b, (char *) inode1); - inode1[off].d1_size += count; - put_block(b, (char *) inode1); - } else { - d2_inode inode2[V2_INODES_PER_BLOCK(BLOCK_SIZE)]; - - get_block(b, (char *) inode2); - inode2[off].d2_size += count; - put_block(b, (char *) inode2); - } -} - - -/*================================================================ - * allocation assist group - *===============================================================*/ -PRIVATE ino_t alloc_inode(mode, usrid, grpid) -int mode, usrid, grpid; -{ - ino_t num; - int off; - block_t b; - - num = next_inode++; - if (num > nrinodes) pexit("File system does not have enough inodes"); - b = ((num - 1) / inodes_per_block) + inode_offset; - off = (num - 1) % inodes_per_block; - if (fs_version == 1) { - d1_inode inode1[V1_INODES_PER_BLOCK]; - - get_block(b, (char *) inode1); - inode1[off].d1_mode = mode; - inode1[off].d1_uid = usrid; - inode1[off].d1_gid = grpid; - put_block(b, (char *) inode1); - } else { - d2_inode inode2[V2_INODES_PER_BLOCK(BLOCK_SIZE)]; - - get_block(b, (char *) inode2); - inode2[off].d2_mode = mode; - inode2[off].d2_uid = usrid; - inode2[off].d2_gid = grpid; - put_block(b, (char *) inode2); - } - - /* Set the bit in the bit map. */ - /* DEBUG FIXME. This assumes the bit is in the first inode map block. */ - insert_bit((block_t) INODE_MAP, (int) num); - return(num); -} - - -PRIVATE zone_t alloc_zone() -{ - /* Allocate a new zone */ - /* Works for zone > block */ - block_t b; - int i; - zone_t z; - - z = next_zone++; - b = z << zone_shift; - if ((b + zone_size) > nrblocks) - pexit("File system not big enough for all the files"); - for (i = 0; i < zone_size; i++) - put_block(b + i, zero); /* give an empty zone */ - /* DEBUG FIXME. This assumes the bit is in the first zone map block. */ - insert_bit(zone_map, (int) (z - zoff)); /* lint, NOT OK because - * z hasn't been broken - * up into block + - * offset yet. */ - return(z); -} - - -void insert_bit(block, bit) -block_t block; -int bit; -{ - /* Insert 'count' bits in the bitmap */ - int w, s; - short buf[BLOCK_SIZE / sizeof(short)]; - - if (block < 0) pexit("insert_bit called with negative argument"); - get_block(block, (char *) buf); - w = bit / (8 * sizeof(short)); - s = bit % (8 * sizeof(short)); - buf[w] |= (1 << s); - put_block(block, (char *) buf); -} - - -/*================================================================ - * proto-file processing assist group - *===============================================================*/ -int mode_con(p) -char *p; -{ - /* Convert string to mode */ - int o1, o2, o3, mode; - char c1, c2, c3; - - c1 = *p++; - c2 = *p++; - c3 = *p++; - o1 = *p++ - '0'; - o2 = *p++ - '0'; - o3 = *p++ - '0'; - mode = (o1 << 6) | (o2 << 3) | o3; - if (c1 == 'd') mode += I_DIRECTORY; - if (c1 == 'b') mode += I_BLOCK_SPECIAL; - if (c1 == 'c') mode += I_CHAR_SPECIAL; - if (c1 == '-') mode += I_REGULAR; - if (c2 == 'u') mode += I_SET_UID_BIT; - if (c3 == 'g') mode += I_SET_GID_BIT; - return(mode); -} - -void getline(line, parse) -char *parse[MAX_TOKENS]; -char line[LINE_LEN]; -{ - /* Read a line and break it up in tokens */ - int k; - char c, *p; - int d; - - for (k = 0; k < MAX_TOKENS; k++) parse[k] = 0; - for (k = 0; k < LINE_LEN; k++) line[k] = 0; - k = 0; - parse[0] = 0; - p = line; - while (1) { - if (++k > LINE_LEN) pexit("Line too long"); - d = fgetc(proto); - if (d == EOF) pexit("Unexpected end-of-file"); - *p = d; - if (*p == '\n') lct++; - if (*p == ' ' || *p == '\t') *p = 0; - if (*p == '\n') { - *p++ = 0; - *p = '\n'; - break; - } - p++; - } - - k = 0; - p = line; - lastp = line; - while (1) { - c = *p++; - if (c == '\n') return; - if (c == 0) continue; - parse[k++] = p - 1; - do { - c = *p++; - } while (c != 0 && c != '\n'); - } -} - - -/*================================================================ - * other stuff - *===============================================================*/ -void check_mtab(devname) -char *devname; /* /dev/hd1 or whatever */ -{ -/* Check to see if the special file named in s is mounted. */ - - int n; - char special[PATH_MAX + 1], mounted_on[PATH_MAX + 1], version[10], rw_flag[10]; - - if (load_mtab("mkfs") < 0) return; - while (1) { - n = get_mtab_entry(special, mounted_on, version, rw_flag); - if (n < 0) return; - if (strcmp(devname, special) == 0) { - /* Can't mkfs on top of a mounted file system. */ - fprintf(stderr, "%s: %s is mounted on %s\n", - progname, devname, mounted_on); - exit(1); - } - } -} - - -long file_time(f) -int f; -{ -#ifdef UNIX - struct stat statbuf; - fstat(f, &statbuf); - return(statbuf.st_mtime); -#else /* fstat not supported by DOS */ - return(0L); -#endif -} - - -void pexit(s) -char *s; -{ - fprintf(stderr, "%s: %s\n", progname, s); - if (lct != 0) - fprintf(stderr, "Line %d being processed when error detected.\n", lct); - flush(); - exit(2); -} - - -void copy(from, to, count) -char *from, *to; -int count; -{ - while (count--) *to++ = *from++; -} - - -void print_fs() -{ - int i, j; - ino_t k; - d1_inode inode1[V1_INODES_PER_BLOCK]; - d2_inode inode2[V2_INODES_PER_BLOCK(BLOCK_SIZE)]; - unsigned short usbuf[BLOCK_SIZE / sizeof(unsigned short)]; - block_t b, inode_limit; - struct direct dir[NR_DIR_ENTRIES(BLOCK_SIZE)]; - - get_block((block_t) 1, (char *) usbuf); - printf("\nSuperblock: "); - for (i = 0; i < 8; i++) printf("%06o ", usbuf[i]); - get_block((block_t) 2, (char *) usbuf); - printf("...\nInode map: "); - for (i = 0; i < 9; i++) printf("%06o ", usbuf[i]); - get_block((block_t) 3, (char *) usbuf); - printf("...\nZone map: "); - for (i = 0; i < 9; i++) printf("%06o ", usbuf[i]); - printf("...\n"); - - k = 0; - for (b = inode_offset; k < nrinodes; b++) { - if (fs_version == 1) { - get_block(b, (char *) inode1); - } else { - get_block(b, (char *) inode2); - } - for (i = 0; i < inodes_per_block; i++) { - k = inodes_per_block * (int) (b - inode_offset) + i + 1; - /* Lint but OK */ - if (k > nrinodes) break; - if (fs_version == 1) { - if (inode1[i].d1_mode != 0) { - printf("Inode %2d: mode=", k); - printf("%06o", inode1[i].d1_mode); - printf(" uid=%2d gid=%2d size=", - inode1[i].d1_uid, inode1[i].d1_gid); - printf("%6ld", inode1[i].d1_size); - printf(" zone[0]=%d\n", inode1[i].d1_zone[0]); - } - if ((inode1[i].d1_mode & I_TYPE) == I_DIRECTORY) { - /* This is a directory */ - get_block(inode1[i].d1_zone[0], (char *) dir); - for (j = 0; j < NR_DIR_ENTRIES(BLOCK_SIZE); j++) - if (dir[j].d_ino) - printf("\tInode %2d: %s\n", dir[j].d_ino, dir[j].d_name); - } - } else { - if (inode2[i].d2_mode != 0) { - printf("Inode %2d: mode=", k); - printf("%06o", inode2[i].d2_mode); - printf(" uid=%2d gid=%2d size=", - inode2[i].d2_uid, inode2[i].d2_gid); - printf("%6ld", inode2[i].d2_size); - printf(" zone[0]=%ld\n", inode2[i].d2_zone[0]); - } - if ((inode2[i].d2_mode & I_TYPE) == I_DIRECTORY) { - /* This is a directory */ - get_block(inode2[i].d2_zone[0], (char *) dir); - for (j = 0; j < NR_DIR_ENTRIES(BLOCK_SIZE); j++) - if (dir[j].d_ino) - printf("\tInode %2d: %s\n", dir[j].d_ino, dir[j].d_name); - } - } - } - } - - printf("%d inodes used. %d zones used.\n", next_inode - 1, next_zone); -} - - -int read_and_set(n) -block_t n; -{ -/* The first time a block is read, it returns all 0s, unless there has - * been a write. This routine checks to see if a block has been accessed. - */ - - int w, s, mask, r; - - if (sizeof(char *) == 2 && n >= MAX_INIT) pexit("can't initialize past 128M"); - w = n / 8; - s = n % 8; - mask = 1 << s; - r = (umap[w] & mask ? 1 : 0); - umap[w] |= mask; - return(r); -} - -void usage() -{ - fprintf(stderr, - "Usage: %s [-1dlot] [-b blocks] [-i inodes] special [proto]\n", - progname); - exit(1); -} - -/*================================================================ - * get_block & put_block for MS-DOS - *===============================================================*/ -#ifdef DOS - -/* - * These are the get_block and put_block routines - * when compiling & running mkfs.c under MS-DOS. - * - * It requires the (asembler) routines absread & abswrite - * from the file diskio.asm. Since these routines just do - * as they are told (read & write the sector specified), - * a local cache is used to minimize the i/o-overhead for - * frequently used blocks. - * - * The global variable "file" determines whether the output - * is to a disk-device or to a binary file. - */ - - -#define PH_SECTSIZE 512 /* size of a physical disk-sector */ - - -char *derrtab[14] = { - "no error", - "disk is read-only", - "unknown unit", - "device not ready", - "bad command", - "data error", - "internal error: bad request structure length", - "seek error", - "unknown media type", - "sector not found", - "printer out of paper (?)", - "write fault", - "read error", - "general error" -}; - -#define CACHE_SIZE 20 /* 20 block-buffers */ - - -struct cache { - char blockbuf[BLOCK_SIZE]; - block_t blocknum; - int dirty; - int usecnt; -} cache[CACHE_SIZE]; - - -void special(string) -char *string; -{ - - if (string[1] == ':' && string[2] == 0) { - /* Format: d: or d:fname */ - disk = (string[0] & ~32) - 'A'; - if (disk > 1 && !override) /* safety precaution */ - pexit("Bad drive specifier for special"); - } else { - file = 1; - if ((fd = creat(string, BWRITE)) == 0) - pexit("Can't open special file"); - } -} - -void get_block(n, buf) -block_t n; -char buf[BLOCK_SIZE]; -{ - /* Get a block to the user */ - struct cache *bp, *fp; - - /* First access returns a zero block */ - if (read_and_set(n) == 0) { - copy(zero, buf, BLOCK_SIZE); - return; - } - - /* Look for block in cache */ - fp = 0; - for (bp = cache; bp < &cache[CACHE_SIZE]; bp++) { - if (bp->blocknum == n) { - copy(bp, buf, BLOCK_SIZE); - bp->usecnt++; - return; - } - - /* Remember clean block */ - if (bp->dirty == 0) - if (fp) { - if (fp->usecnt > bp->usecnt) fp = bp; - } else - fp = bp; - } - - /* Block not in cache, get it */ - if (!fp) { - /* No clean buf, flush one */ - for (bp = cache, fp = cache; bp < &cache[CACHE_SIZE]; bp++) - if (fp->usecnt > bp->usecnt) fp = bp; - mx_write(fp->blocknum, fp); - } - mx_read(n, fp); - fp->dirty = 0; - fp->usecnt = 0; - fp->blocknum = n; - copy(fp, buf, BLOCK_SIZE); -} - -void put_block(n, buf) -block_t n; -char buf[BLOCK_SIZE]; -{ - /* Accept block from user */ - struct cache *fp, *bp; - - (void) read_and_set(n); - - /* Look for block in cache */ - fp = 0; - for (bp = cache; bp < &cache[CACHE_SIZE]; bp++) { - if (bp->blocknum == n) { - copy(buf, bp, BLOCK_SIZE); - bp->dirty = 1; - return; - } - - /* Remember clean block */ - if (bp->dirty == 0) - if (fp) { - if (fp->usecnt > bp->usecnt) fp = bp; - } else - fp = bp; - } - - /* Block not in cache */ - if (!fp) { - /* No clean buf, flush one */ - for (bp = cache, fp = cache; bp < &cache[CACHE_SIZE]; bp++) - if (fp->usecnt > bp->usecnt) fp = bp; - mx_write(fp->blocknum, fp); - } - fp->dirty = 1; - fp->usecnt = 1; - fp->blocknum = n; - copy(buf, fp, BLOCK_SIZE); -} - -void cache_init() -{ - struct cache *bp; - for (bp = cache; bp < &cache[CACHE_SIZE]; bp++) bp->blocknum = -1; -} - -void flush() -{ - /* Flush all dirty blocks to disk */ - struct cache *bp; - - for (bp = cache; bp < &cache[CACHE_SIZE]; bp++) - if (bp->dirty) { - mx_write(bp->blocknum, bp); - bp->dirty = 0; - } -} - -/*================================================================== - * hard read & write etc. - *=================================================================*/ -#define MAX_RETRIES 5 - - -void mx_read(blocknr, buf) -int blocknr; -char buf[BLOCK_SIZE]; -{ - - /* Read the requested MINIX-block in core */ - char (*bp)[PH_SECTSIZE]; - int sectnum, retries, err; - - if (file) { - lseek(fd, (off_t) blocknr * BLOCK_SIZE, 0); - if (read(fd, buf, BLOCK_SIZE) != BLOCK_SIZE) - pexit("mx_read: error reading file"); - } else { - sectnum = blocknr * (BLOCK_SIZE / PH_SECTSIZE); - for (bp = buf; bp < &buf[BLOCK_SIZE]; bp++) { - retries = MAX_RETRIES; - do - err = absread(disk, sectnum, bp); - while (err && --retries); - - if (retries) { - sectnum++; - } else { - dexit("mx_read", sectnum, err); - } - } - } -} - -void mx_write(blocknr, buf) -int blocknr; -char buf[BLOCK_SIZE]; -{ - /* Write the MINIX-block to disk */ - char (*bp)[PH_SECTSIZE]; - int retries, sectnum, err; - - if (file) { - lseek(fd, blocknr * BLOCK_SIZE, 0); - if (write(fd, buf, BLOCK_SIZE) != BLOCK_SIZE) { - pexit("mx_write: error writing file"); - } - } else { - sectnum = blocknr * (BLOCK_SIZE / PH_SECTSIZE); - for (bp = buf; bp < &buf[BLOCK_SIZE]; bp++) { - retries = MAX_RETRIES; - do { - err = abswrite(disk, sectnum, bp); - } while (err && --retries); - - if (retries) { - sectnum++; - } else { - dexit("mx_write", sectnum, err); - } - } - } -} - - -void dexit(s, sectnum, err) -int sectnum, err; -char *s; -{ - printf("Error: %s, sector: %d, code: %d, meaning: %s\n", - s, sectnum, err, derrtab[err]); - exit(2); -} - -#endif - -/*================================================================ - * get_block & put_block for UNIX - *===============================================================*/ -#ifdef UNIX - -void special(string) -char *string; -{ - fd = creat(string, 0777); - close(fd); - fd = open(string, O_RDWR); - if (fd < 0) pexit("Can't open special file"); -} - - - -void get_block(n, buf) -block_t n; -char buf[BLOCK_SIZE]; -{ -/* Read a block. */ - - int k; - - /* First access returns a zero block */ - if (read_and_set(n) == 0) { - copy(zero, buf, BLOCK_SIZE); - return; - } - lseek(fd, (off_t) n * BLOCK_SIZE, SEEK_SET); - k = read(fd, buf, BLOCK_SIZE); - if (k != BLOCK_SIZE) { - pexit("get_block couldn't read"); - } -} - -void put_block(n, buf) -block_t n; -char buf[BLOCK_SIZE]; -{ -/* Write a block. */ - - (void) read_and_set(n); - - /* XXX - check other lseeks too. */ - if (lseek(fd, (off_t) n * BLOCK_SIZE, SEEK_SET) == (off_t) -1) { - pexit("put_block couldn't seek"); - } - if (write(fd, buf, BLOCK_SIZE) != BLOCK_SIZE) { - pexit("put_block couldn't write"); - } -} - - -/* Dummy routines to keep source file clean from #ifdefs */ - -void flush() -{ - return; -} - -void cache_init() -{ - return; -} - -#endif diff --git a/commands/size/Makefile b/commands/size/Makefile new file mode 100644 index 000000000..791a877c3 --- /dev/null +++ b/commands/size/Makefile @@ -0,0 +1,4 @@ +PROG= size +MAN= + +.include diff --git a/commands/simple/size.c b/commands/size/size.c similarity index 100% rename from commands/simple/size.c rename to commands/size/size.c diff --git a/commands/sleep/Makefile b/commands/sleep/Makefile new file mode 100644 index 000000000..3c398c1c1 --- /dev/null +++ b/commands/sleep/Makefile @@ -0,0 +1,4 @@ +PROG= sleep +MAN= + +.include diff --git a/commands/simple/sleep.c b/commands/sleep/sleep.c similarity index 100% rename from commands/simple/sleep.c rename to commands/sleep/sleep.c diff --git a/commands/slip/Makefile b/commands/slip/Makefile new file mode 100644 index 000000000..9132a9ab4 --- /dev/null +++ b/commands/slip/Makefile @@ -0,0 +1,4 @@ +PROG= slip +MAN= + +.include diff --git a/commands/simple/slip.c b/commands/slip/slip.c similarity index 100% rename from commands/simple/slip.c rename to commands/slip/slip.c diff --git a/commands/sort/Makefile b/commands/sort/Makefile new file mode 100644 index 000000000..4dc558e0c --- /dev/null +++ b/commands/sort/Makefile @@ -0,0 +1,4 @@ +PROG= sort +MAN= + +.include diff --git a/commands/simple/sort.c b/commands/sort/sort.c similarity index 100% rename from commands/simple/sort.c rename to commands/sort/sort.c diff --git a/commands/spell/Makefile b/commands/spell/Makefile new file mode 100644 index 000000000..d1e3acf94 --- /dev/null +++ b/commands/spell/Makefile @@ -0,0 +1,4 @@ +SCRIPTS= spell.sh +MAN= + +.include diff --git a/commands/scripts/spell.sh b/commands/spell/spell.sh old mode 100755 new mode 100644 similarity index 100% rename from commands/scripts/spell.sh rename to commands/spell/spell.sh diff --git a/commands/split/Makefile b/commands/split/Makefile new file mode 100644 index 000000000..6000d45cb --- /dev/null +++ b/commands/split/Makefile @@ -0,0 +1,4 @@ +PROG= split +MAN= + +.include diff --git a/commands/simple/split.c b/commands/split/split.c similarity index 100% rename from commands/simple/split.c rename to commands/split/split.c diff --git a/commands/srccrc/Makefile b/commands/srccrc/Makefile new file mode 100644 index 000000000..1ecca6ae2 --- /dev/null +++ b/commands/srccrc/Makefile @@ -0,0 +1,4 @@ +SCRIPTS= srccrc.sh +MAN= + +.include diff --git a/commands/scripts/srccrc.sh b/commands/srccrc/srccrc.sh old mode 100755 new mode 100644 similarity index 100% rename from commands/scripts/srccrc.sh rename to commands/srccrc/srccrc.sh diff --git a/commands/stat/Makefile b/commands/stat/Makefile new file mode 100644 index 000000000..6583d71fc --- /dev/null +++ b/commands/stat/Makefile @@ -0,0 +1,7 @@ +PROG= stat +MAN= + +LINKS+= ${BINDIR}/stat ${BINDIR}/readlink +LINKS+= ${BINDIR}/stat ${BINDIR}/fstat + +.include diff --git a/commands/simple/stat.c b/commands/stat/stat.c similarity index 100% rename from commands/simple/stat.c rename to commands/stat/stat.c diff --git a/commands/strings/Makefile b/commands/strings/Makefile new file mode 100644 index 000000000..23d43b8c4 --- /dev/null +++ b/commands/strings/Makefile @@ -0,0 +1,4 @@ +PROG= strings +MAN= + +.include diff --git a/commands/simple/strings.c b/commands/strings/strings.c similarity index 100% rename from commands/simple/strings.c rename to commands/strings/strings.c diff --git a/commands/strip/Makefile b/commands/strip/Makefile new file mode 100644 index 000000000..acba06683 --- /dev/null +++ b/commands/strip/Makefile @@ -0,0 +1,4 @@ +PROG= strip +MAN= + +.include diff --git a/commands/simple/strip.c b/commands/strip/strip.c similarity index 100% rename from commands/simple/strip.c rename to commands/strip/strip.c diff --git a/commands/stty/Makefile b/commands/stty/Makefile new file mode 100644 index 000000000..a1aff7f41 --- /dev/null +++ b/commands/stty/Makefile @@ -0,0 +1,4 @@ +PROG= stty +MAN= + +.include diff --git a/commands/simple/stty.c b/commands/stty/stty.c similarity index 100% rename from commands/simple/stty.c rename to commands/stty/stty.c diff --git a/commands/su/Makefile b/commands/su/Makefile new file mode 100644 index 000000000..35bc6f32d --- /dev/null +++ b/commands/su/Makefile @@ -0,0 +1,5 @@ +PROG= su +BINMODE= 4755 +MAN= + +.include diff --git a/commands/simple/su.c b/commands/su/su.c similarity index 100% rename from commands/simple/su.c rename to commands/su/su.c diff --git a/commands/sum/Makefile b/commands/sum/Makefile new file mode 100644 index 000000000..fad71518c --- /dev/null +++ b/commands/sum/Makefile @@ -0,0 +1,4 @@ +PROG= sum +MAN= + +.include diff --git a/commands/simple/sum.c b/commands/sum/sum.c similarity index 100% rename from commands/simple/sum.c rename to commands/sum/sum.c diff --git a/commands/svclog/Makefile b/commands/svclog/Makefile new file mode 100644 index 000000000..a5f6155f8 --- /dev/null +++ b/commands/svclog/Makefile @@ -0,0 +1,4 @@ +SCRIPTS= svclog.sh +MAN= + +.include diff --git a/commands/scripts/svclog.sh b/commands/svclog/svclog.sh old mode 100755 new mode 100644 similarity index 100% rename from commands/scripts/svclog.sh rename to commands/svclog/svclog.sh diff --git a/commands/swapfs/Makefile b/commands/swapfs/Makefile new file mode 100644 index 000000000..4cc5f18a8 --- /dev/null +++ b/commands/swapfs/Makefile @@ -0,0 +1,4 @@ +PROG= swapfs +MAN= + +.include diff --git a/commands/simple/swapfs.c b/commands/swapfs/swapfs.c similarity index 100% rename from commands/simple/swapfs.c rename to commands/swapfs/swapfs.c diff --git a/commands/swifi/Makefile b/commands/swifi/Makefile index 5ddb56c20..c10380328 100644 --- a/commands/swifi/Makefile +++ b/commands/swifi/Makefile @@ -1,23 +1,9 @@ -OBJ=systest.o fault_model.o extra.o db_sym.o db_disasm.o db_access.o read_nlist.o -OBJ_RND=rnd.o -OBJ_SOCKET=socket.o +# swifi Makefile -DEFINES=-DCONFIG_SWIFI -CFLAGS=$(DEFINES) +PROG= swifi +SRCS= systest.c fault_model.c extra.c db_sym.c db_disasm.c \ + db_access.c read_nlist.c +CPPFLAGS+= -DCONFIG_SWIFI +MAN= -all: swifi rnd socket - -install: swifi - install swifi /usr/bin/swifi - -swifi: $(OBJ) - $(CC) -o swifi $(OBJ) - -rnd: $(OBJ_RND) - $(CC) -o $@ $(OBJ_RND) - -socket: $(OBJ_SOCKET) - $(CC) -o $@ $(OBJ_SOCKET) - -clean: - rm -f swifi $(OBJ) +.include diff --git a/commands/swifi/ddb.h b/commands/swifi/ddb.h index 24a47eed5..926e37ee5 100644 --- a/commands/swifi/ddb.h +++ b/commands/swifi/ddb.h @@ -40,8 +40,6 @@ #define __P(protos) protos typedef int boolean_t; typedef unsigned long vm_offset_t; -unsigned long random __P((void)); -void srandom __P((unsigned long)); #include "db_machdep.h" /* type definitions */ diff --git a/commands/sync/Makefile b/commands/sync/Makefile new file mode 100644 index 000000000..3d9a01bab --- /dev/null +++ b/commands/sync/Makefile @@ -0,0 +1,5 @@ +PROG= sync +BINDIR= /bin +MAN= + +.include diff --git a/commands/simple/sync.c b/commands/sync/sync.c similarity index 100% rename from commands/simple/sync.c rename to commands/sync/sync.c diff --git a/commands/synctree/Makefile b/commands/synctree/Makefile new file mode 100644 index 000000000..1895460c6 --- /dev/null +++ b/commands/synctree/Makefile @@ -0,0 +1,5 @@ +PROG= synctree +CPPFLAGS+= -wo +MAN= + +.include diff --git a/commands/simple/synctree.c b/commands/synctree/synctree.c similarity index 100% rename from commands/simple/synctree.c rename to commands/synctree/synctree.c diff --git a/commands/sysenv/Makefile b/commands/sysenv/Makefile new file mode 100644 index 000000000..26fa396a0 --- /dev/null +++ b/commands/sysenv/Makefile @@ -0,0 +1,5 @@ +PROG= sysenv +BINDIR= /bin +MAN= + +.include diff --git a/commands/simple/sysenv.c b/commands/sysenv/sysenv.c similarity index 100% rename from commands/simple/sysenv.c rename to commands/sysenv/sysenv.c diff --git a/commands/syslogd/Makefile b/commands/syslogd/Makefile index 5ac4b66cf..386579092 100644 --- a/commands/syslogd/Makefile +++ b/commands/syslogd/Makefile @@ -4,40 +4,10 @@ ## Makefile for syslogd/klogd ## $Id$ -BINDIR = /usr/bin +PROG= syslogd +PIDFILE= -DPIDFILE=\"/var/run/syslogd.pid\" +CPPFLAGS+= -Ddebug=0 ${PIDFILE} +BINMODE= 700 +MAN= -CC = exec cc -RM = rm -f -EXTRA = -DPIDFILE=\"/var/run/syslogd.pid\" -CPPFLAGS= -D_MINIX -D_POSIX_SOURCE -Ddebug=0 $(EXTRA) -I. -CFLAGS = -m -O $(CPPFLAGS) -MKDEP = mkdep "$(CC) -E $(CPPFLAGS)" -LDFLAGS = -i -o $@ -TARGETS = logger syslogd - -SRCS = logger.c syslog.c syslog_test.c syslogd.c -OBJS = logger.o syslog.o syslog_test.o syslogd.o - -all: $(TARGETS) - -syslogd: syslogd.o - $(CC) $? $(LDFLAGS) - @install $@ - -syslog_test: syslog_test.o syslog.o - $(CC) syslog_test.o syslog.o $(LDFLAGS) - @install -S 2kw $@ - -logger: logger.o syslog.o - $(CC) logger.o syslog.o $(LDFLAGS) - -clean: - $(RM) $(OBJS) $(TARGETS) syslog_test *.BAK core - -install: $(BINDIR)/logger $(BINDIR)/syslog_test $(BINDIR)/syslogd -$(BINDIR)/logger: logger - install -cs -m 755 -o bin -g operator $? $@ -$(BINDIR)/syslog_test: syslog_test - install -cs -m 755 -o bin -g operator $? $@ -$(BINDIR)/syslogd: syslogd - install -cs -m 700 -o root -g operator $? $@ +.include diff --git a/commands/syslogd/syslog.c b/commands/syslogd/syslog.c deleted file mode 100644 index 8db82df3c..000000000 --- a/commands/syslogd/syslog.c +++ /dev/null @@ -1,167 +0,0 @@ -/* Copyright (c) 1983, 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * #if defined(LIBC_SCCS) && !defined(lint) - * static char sccsid[] = "@(#)syslog.c 8.4 (Berkeley) 3/18/94"; - * #endif - * - * Author: Eric Allman - * Modified to use UNIX domain IPC by Ralph Campbell - * Patched March 12, 1996 by A. Ian Vogelesang - * Rewritten by Martin Mares on May 14, 1997 - * Rewritten by G. Falzoni for porting to Minix - * - * $Id$ - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static int LogPid = (-1); -static int nfd = (-1); -static int LogFacility = LOG_USER; -static int LogFlags = 0; -static char TagBuffer[40] = "syslog"; - -/* -** OPENLOG -- open system log -** - establishes a channel to syslogd using UDP device -** (port 514 is used _ syslog/udp) -** - stores program tag (if not NULL) and other options -** for use by syslog -*/ -void openlog(const char *ident, int option, int facility) -{ - struct nwio_udpopt udpopt; - - /* Stores logging flags */ - LogFlags = option & (LOG_PID | LOG_PERROR | LOG_CONS); - /* Stores process id. if LOG_PID was specified */ - if (option & LOG_PID) LogPid = getpid(); - /* Stores the requested facility */ - LogFacility = facility; - /* Stores log tag if supplied */ - if (ident != NULL && *ident != '0' && ident != TagBuffer) { - strncpy(TagBuffer, ident, sizeof(TagBuffer)); - TagBuffer[sizeof(TagBuffer) - 1] = '0'; - } - - /* Opens channel to syslog daemon via UDP device */ - /* Static values used to minimize code */ - if (option & LOG_NDELAY) { - /* Opens UDP device */ - if ((nfd = open(UDP_DEVICE, O_RDWR)) < 0) { - /* Report error */ ; - } - /* Sets options for UDP device */ - udpopt.nwuo_flags = NWUO_SHARED | NWUO_LP_SET | NWUO_DI_LOC | - NWUO_DI_BROAD | NWUO_RP_SET | NWUO_RA_SET | - NWUO_RWDATONLY | NWUO_DI_IPOPT; - udpopt.nwuo_locaddr = udpopt.nwuo_remaddr = htonl(0x7F000001L); - udpopt.nwuo_locport = udpopt.nwuo_remport = htons(514); - if (ioctl(nfd, NWIOSUDPOPT, &udpopt) < 0 || - ioctl(nfd, NWIOGUDPOPT, &udpopt) < 0) { - /* Report error */ ; - } - } - return; -} - -/* -** SYSLOG -- print message on log file -** -** This routine looks a lot like printf, except that it outputs to the -** log file instead of the standard output. Also: -** - adds a timestamp, -** - prints the module name in front of the message, -** - has some other formatting types (or will sometime), -** - adds a newline on the end of the message. -** -** The output of this routine is intended to be read by syslogd(8). -*/ -void syslog(int lprty, const char *msg,...) -{ - time_t now; - char buff[512]; - int len, rc; - va_list ap; - - /* First log message open chnnel to syslog */ - if (nfd < 0) openlog(TagBuffer, LogFlags | LOG_NDELAY, LogFacility); - time(&now); - len = sprintf(buff, "<%d>%.15s %s: ", - LogFacility | lprty, ctime(&now) + 4, TagBuffer); - if (LogFlags & LOG_PID) { - len -= 2; - len += sprintf(buff + len, "[%d]: ", LogPid); - } - va_start(ap, msg); - len += vsnprintf(buff + len, sizeof(buff) - len, msg, ap); - va_end(ap); - rc = write(nfd, buff, len); - if ((rc != len && LogFlags & LOG_CONS) || LogFlags & LOG_PERROR) { - write(STDERR_FILENO, buff, len); - write(STDERR_FILENO, "\n", 1); - } - return; -} - -/* -** CLOSELOG -- close access to syslogd -** - closes UDP channel -** - restores default values -*/ -void closelog(void) -{ - - close(nfd); - LogPid = nfd = -1; - LogFacility = LOG_USER; - LogFlags = 0; - return; -} - -/** syslog.c **/ diff --git a/commands/syslogd/syslog_test.c b/commands/syslogd/syslog_test.c deleted file mode 100644 index 9a5bced9d..000000000 --- a/commands/syslogd/syslog_test.c +++ /dev/null @@ -1,30 +0,0 @@ -/* -** syslog_test -** -** Author: Giovanni Falzoni -** $Id$ -*/ - -#include -#include -#include - -/* -** SYSLOG TEST -** Very simple utility to test syslog facility. -*/ -void main(void) -{ - int ix; - - openlog("syslog_test", LOG_PID | LOG_NDELAY | LOG_PERROR | LOG_CONS, LOG_DAEMON); - - for (ix = LOG_EMERG; ix <= LOG_DEBUG; ix += 1) { - sleep(2); - syslog(ix, "message from test program - log level %d", ix); - } - closelog(); - return; -} - -/** syslog_test.c **/ diff --git a/commands/tail/Makefile b/commands/tail/Makefile new file mode 100644 index 000000000..6bbcd4df1 --- /dev/null +++ b/commands/tail/Makefile @@ -0,0 +1,4 @@ +PROG= tail +MAN= + +.include diff --git a/commands/simple/tail.c b/commands/tail/tail.c similarity index 100% rename from commands/simple/tail.c rename to commands/tail/tail.c diff --git a/commands/talk/Makefile b/commands/talk/Makefile index ff863d0e1..55cc1cc99 100644 --- a/commands/talk/Makefile +++ b/commands/talk/Makefile @@ -3,29 +3,11 @@ # 08/01/96 Michael Temari, # -CFLAGS= -O -D_MINIX -D_POSIX_SOURCE -LDFLAGS=-i -BINDIR= /usr/bin PROG= talk -CC = exec cc +SRCS= talk.c screen.c net.c proto.c +MAN= -OBJS= talk.o screen.o net.o proto.o +DPADD+= ${LIBCURSES} +LDADD+= -lcurses -all: $(PROG) - -$(PROG): $(OBJS) - $(CC) $(LDFLAGS) -o $@ $(OBJS) -lcurses - install -S 16kw $@ - -clean: - rm -f $(PROG) $(OBJS) - -install: $(BINDIR)/$(PROG) - -$(BINDIR)/$(PROG): $(PROG) - install -cs -o bin $? $@ - -talk.o: talk.c talk.h proto.h net.h screen.h -screen.o: screen.c screen.h -net.o: net.c talk.h net.h -proto.o: proto.c talk.h proto.h net.h screen.h +.include diff --git a/commands/talk/build b/commands/talk/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/talk/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/talkd/Makefile b/commands/talkd/Makefile index 684fd4bb9..f6da58694 100644 --- a/commands/talkd/Makefile +++ b/commands/talkd/Makefile @@ -3,29 +3,8 @@ # 07/22/96 Michael Temari, # -CFLAGS= -O -D_MINIX -D_POSIX_SOURCE -LDFLAGS=-i -BINDIR= /usr/bin PROG= talkd -CC = exec cc +SRCS= talkd.c net.c process.c finduser.c +MAN= -OBJS= talkd.o net.o process.o finduser.o - -all: $(PROG) - -$(PROG): $(OBJS) - $(CC) $(LDFLAGS) -o $@ $(OBJS) - install -S 8kw $@ - -clean: - rm -f $(PROG) $(OBJS) - -install: $(BINDIR)/$(PROG) - -$(BINDIR)/$(PROG): $(PROG) - install -cs -o bin $? $@ - -talkd.o: talkd.c talk.h talkd.h process.h net.h -net.o: net.c talk.h talkd.h net.h -process.o: process.c talk.h talkd.h finduser.h process.h -finduser.o: finduser.c talk.h finduser.h +.include diff --git a/commands/talkd/build b/commands/talkd/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/talkd/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/tcpd/Makefile b/commands/tcpd/Makefile new file mode 100644 index 000000000..e9f3f62eb --- /dev/null +++ b/commands/tcpd/Makefile @@ -0,0 +1,5 @@ +PROG= tcpd +CPPFLAGS+= -DPARANOID=0 +MAN= + +.include diff --git a/commands/simple/tcpd.c b/commands/tcpd/tcpd.c similarity index 100% rename from commands/simple/tcpd.c rename to commands/tcpd/tcpd.c diff --git a/commands/tcpdp/Makefile b/commands/tcpdp/Makefile new file mode 100644 index 000000000..3146a335e --- /dev/null +++ b/commands/tcpdp/Makefile @@ -0,0 +1,10 @@ +.include + +PROG= tcpdp +SRCS= tcpd.c +CPPFLAGS+= -DPARANOID=1 +MAN= + +.PATH: ${MINIXSRCDIR}/commands/tcpd + +.include diff --git a/commands/tcpdp/tcpd.c b/commands/tcpdp/tcpd.c new file mode 100644 index 000000000..e8f3948a7 --- /dev/null +++ b/commands/tcpdp/tcpd.c @@ -0,0 +1,311 @@ +/* +tcpd.c +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* This program can be compiled to be paranoid, i.e. check incoming connection + * according to an access file, or to trust anyone. The much smaller "trust + * 'em" binary will call the paranoid version if the access file exists. + */ + +static char *arg0, *service; +static unsigned nchildren; + +static void report(const char *label) +{ + int err= errno; + + fprintf(stderr, "%s %s: %s: %s\n", arg0, service, label, strerror(err)); + errno= err; +} + +static void sigchld(int sig) +{ + while (waitpid(0, NULL, WNOHANG) > 0) { + if (nchildren > 0) nchildren--; + } +} + +static void release(int *fd) +{ + if (*fd != -1) { + close(*fd); + *fd= -1; + } +} + +static void usage(void) +{ + fprintf(stderr, + "Usage: %s [-d] [-m maxclients] service program [arg ...]\n", + arg0); + exit(1); +} + +int main(int argc, char **argv) +{ + tcpport_t port; + int last_failed = 0; + struct nwio_tcpcl tcplistenopt; + struct nwio_tcpconf tcpconf; + struct nwio_tcpopt tcpopt; + char *tcp_device; + struct servent *servent; + int tcp_fd, client_fd, count, r; + int pfd[2]; + unsigned stall= 0; + struct sigaction sa; + sigset_t chldmask, chldunmask, oldmask; + char **progv; + +#if !PARANOID +# define debug 0 +# define max_children ((unsigned) -1) + arg0= argv[0]; + + /* Switch to the paranoid version of me if there are flags, or if + * there is an access file. + */ + if (argv[1][0] == '-' || access(_PATH_SERVACCES, F_OK) == 0) { + execv("/usr/bin/tcpdp", argv); + report("tcpdp"); + exit(1); + } + if (argc < 3) usage(); + service= argv[1]; + progv= argv+2; + +#else /* PARANOID */ + int debug, i; + unsigned max_children; + + arg0= argv[0]; + debug= 0; + max_children= -1; + i= 1; + while (i < argc && argv[i][0] == '-') { + char *opt= argv[i++] + 1; + unsigned long m; + char *end; + + if (*opt == '-' && opt[1] == 0) break; /* -- */ + + while (*opt != 0) switch (*opt++) { + case 'd': + debug= 1; + break; + case 'm': + if (*opt == 0) { + if (i == argc) usage(); + opt= argv[i++]; + } + m= strtoul(opt, &end, 10); + if (m <= 0 || m > UINT_MAX || *end != 0) usage(); + max_children= m; + opt= ""; + break; + default: + usage(); + } + } + service= argv[i++]; + progv= argv+i; + if (i >= argc) usage(); +#endif + + /* The interface to start the service on. */ + if ((tcp_device= getenv("TCP_DEVICE")) == NULL) tcp_device= TCP_DEVICE; + + /* Let SIGCHLD interrupt whatever I'm doing. */ + sigemptyset(&chldmask); + sigaddset(&chldmask, SIGCHLD); + sigprocmask(SIG_BLOCK, &chldmask, &oldmask); + chldunmask= oldmask; + sigdelset(&chldunmask, SIGCHLD); + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + sa.sa_handler = sigchld; + sigaction(SIGCHLD, &sa, NULL); + + /* Open a socket to the service I'm to serve. */ + if ((servent= getservbyname(service, "tcp")) == NULL) { + unsigned long p; + char *end; + + p= strtoul(service, &end, 0); + if (p <= 0 || p > 0xFFFF || *end != 0) { + fprintf(stderr, "%s: %s: Unknown service\n", + arg0, service); + exit(1); + } + port= htons((tcpport_t) p); + } else { + port= servent->s_port; + + if (debug) + { + fprintf(stderr, "%s %s: listening to port %u\n", + arg0, service, ntohs(port)); + } + } + + /* No client yet. */ + client_fd= -1; + + while (1) { + if ((tcp_fd= open(tcp_device, O_RDWR)) < 0) { + report(tcp_device); +#if 0 + if (errno == ENOENT || errno == ENODEV + || errno == ENXIO) { + exit(1); + } +#endif + last_failed = 1; + goto bad; + } + if(last_failed) + fprintf(stderr, "%s %s: %s: Ok\n", + arg0, service, tcp_device); + last_failed = 0; + + tcpconf.nwtc_flags= NWTC_LP_SET | NWTC_UNSET_RA | NWTC_UNSET_RP; + tcpconf.nwtc_locport= port; + + if (ioctl(tcp_fd, NWIOSTCPCONF, &tcpconf) < 0) { + report("Can't configure TCP channel"); + exit(1); + } + + tcpopt.nwto_flags= NWTO_DEL_RST; + + if (ioctl(tcp_fd, NWIOSTCPOPT, &tcpopt) < 0) { + report("Can't set TCP options"); + exit(1); + } + + if (client_fd != -1) { + /* We have a client, so start a server for it. */ + + tcpopt.nwto_flags= 0; + (void) ioctl(client_fd, NWIOSTCPOPT, &tcpopt); + + fflush(NULL); + + /* Create a pipe to serve as an error indicator. */ + if (pipe(pfd) < 0) { + report("pipe"); + goto bad; + } + (void) fcntl(pfd[1], F_SETFD, + fcntl(pfd[1], F_GETFD) | FD_CLOEXEC); + + /* Fork and exec. */ + switch (fork()) { + case -1: + report("fork"); + close(pfd[0]); + close(pfd[1]); + goto bad; + case 0: + close(tcp_fd); + close(pfd[0]); +#if PARANOID + /* Check if access to this service allowed. */ + if (ioctl(client_fd, NWIOGTCPCONF, &tcpconf) == 0 + && tcpconf.nwtc_remaddr != tcpconf.nwtc_locaddr + && !servxcheck(tcpconf.nwtc_remaddr, service, NULL) + ) { + exit(1); + } +#endif + sigprocmask(SIG_SETMASK, &oldmask, NULL); + dup2(client_fd, 0); + dup2(client_fd, 1); + close(client_fd); + execvp(progv[0], progv); + report(progv[0]); + write(pfd[1], &errno, sizeof(errno)); + exit(1); + default: + nchildren++; + release(&client_fd); + close(pfd[1]); + r= read(pfd[0], &errno, sizeof(errno)); + close(pfd[0]); + if (r != 0) goto bad; + break; + } + } + + while (nchildren >= max_children) { + /* Too many clients, wait for one to die off. */ + sigsuspend(&chldunmask); + } + + /* Wait for a new connection. */ + sigprocmask(SIG_UNBLOCK, &chldmask, NULL); + + tcplistenopt.nwtcl_flags= 0; + while (ioctl(tcp_fd, NWIOTCPLISTEN, &tcplistenopt) < 0) { + if (errno != EINTR) { + if (errno != EAGAIN || debug) { + report("Unable to listen"); + } + goto bad; + } + } + sigprocmask(SIG_BLOCK, &chldmask, NULL); + + /* We got a connection. */ + client_fd= tcp_fd; + tcp_fd= -1; + + if (debug && ioctl(client_fd, NWIOGTCPCONF, &tcpconf) == 0) { + fprintf(stderr, "%s %s: Connection from %s:%u\n", + arg0, service, + inet_ntoa(tcpconf.nwtc_remaddr), + ntohs(tcpconf.nwtc_remport)); + } + /* All is well, no need to stall. */ + stall= 0; + continue; + + bad: + /* All is not well, release resources. */ + release(&tcp_fd); + release(&client_fd); + + /* Wait a bit if this happens more than once. */ + if (stall != 0) { + if (debug) { + fprintf(stderr, "%s %s: stalling %u second%s\n", + arg0, service, + stall, stall == 1 ? "" : "s"); + } + sleep(stall); + stall <<= 1; + } else { + stall= 1; + } + } +} diff --git a/commands/tcpstat/Makefile b/commands/tcpstat/Makefile new file mode 100644 index 000000000..c21751eaa --- /dev/null +++ b/commands/tcpstat/Makefile @@ -0,0 +1,5 @@ +PROG= tcpstat +CPPFLAGS+= -I${MINIXSRCDIR}/servers +MAN= + +.include diff --git a/commands/simple/tcpstat.c b/commands/tcpstat/tcpstat.c similarity index 100% rename from commands/simple/tcpstat.c rename to commands/tcpstat/tcpstat.c diff --git a/commands/tee/Makefile b/commands/tee/Makefile new file mode 100644 index 000000000..a3e01556b --- /dev/null +++ b/commands/tee/Makefile @@ -0,0 +1,4 @@ +PROG= tee +MAN= + +.include diff --git a/commands/simple/tee.c b/commands/tee/tee.c similarity index 100% rename from commands/simple/tee.c rename to commands/tee/tee.c diff --git a/commands/telnet/Makefile b/commands/telnet/Makefile index 6d215550f..38d93c70e 100644 --- a/commands/telnet/Makefile +++ b/commands/telnet/Makefile @@ -1,21 +1,7 @@ # Makefile for telnet -CFLAGS= -D_MINIX -D_POSIX_SOURCE -LDFLAGS=-i -CC = exec cc +PROG= ttn +SRCS= ttn.c ttn_conf.c +MAN= -SRC= ttn.c ttn_conf.c - -all: ttn - -ttn: $(SRC) - $(CC) $(CFLAGS) $(LDFLAGS) -o ttn $(SRC) - install -S 4kw $@ - -clean: - rm -f ttn - -install: /usr/bin/telnet - -/usr/bin/telnet: ttn - install -cs -o bin ttn $@ +.include diff --git a/commands/telnet/build b/commands/telnet/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/telnet/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/telnetd/Makefile b/commands/telnetd/Makefile index 6f6895646..310451a8b 100644 --- a/commands/telnetd/Makefile +++ b/commands/telnetd/Makefile @@ -3,30 +3,8 @@ # 01/30/96 Initial Release Michael Temari, # -CFLAGS= -O -D_MINIX -D_POSIX_SOURCE -LDFLAGS=-i -BINDIR= /usr/bin PROG= in.telnetd -CC = exec cc +SRCS= main.c telnet.c term.c pty.c wtmp.c +MAN= -OBJS= main.o telnet.o term.o pty.o wtmp.o - -all: $(PROG) - -$(PROG): $(OBJS) - $(CC) $(LDFLAGS) -o $@ $(OBJS) - install -S 8kw $@ - -clean: - rm -f $(PROG) $(OBJS) - -install: $(BINDIR)/$(PROG) - -$(BINDIR)/$(PROG): $(PROG) - install -cs -o bin $? $@ - -main.o: main.c telnetd.h -telnet.o: telnet.c telnetd.h telnet.h -term.o: term.c telnetd.h telnet.h -pty.o: pty.c telnetd.h -wtmp.o: telnetd.h +.include diff --git a/commands/telnetd/build b/commands/telnetd/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/telnetd/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/term/Makefile b/commands/term/Makefile new file mode 100644 index 000000000..fa668ff7a --- /dev/null +++ b/commands/term/Makefile @@ -0,0 +1,6 @@ +PROG= term +BINGRP= uucp +BINMODE= 2755 +MAN= + +.include diff --git a/commands/simple/term.c b/commands/term/term.c similarity index 100% rename from commands/simple/term.c rename to commands/term/term.c diff --git a/commands/termcap/Makefile b/commands/termcap/Makefile new file mode 100644 index 000000000..acaa95f69 --- /dev/null +++ b/commands/termcap/Makefile @@ -0,0 +1,4 @@ +PROG= termcap +MAN= + +.include diff --git a/commands/simple/termcap.c b/commands/termcap/termcap.c similarity index 100% rename from commands/simple/termcap.c rename to commands/termcap/termcap.c diff --git a/commands/tget/Makefile b/commands/tget/Makefile new file mode 100644 index 000000000..a7dd19b4d --- /dev/null +++ b/commands/tget/Makefile @@ -0,0 +1,4 @@ +PROG= tget +MAN= + +.include diff --git a/commands/simple/tget.c b/commands/tget/tget.c similarity index 100% rename from commands/simple/tget.c rename to commands/tget/tget.c diff --git a/commands/time/Makefile b/commands/time/Makefile new file mode 100644 index 000000000..366d7e878 --- /dev/null +++ b/commands/time/Makefile @@ -0,0 +1,4 @@ +PROG= time +MAN= + +.include diff --git a/commands/simple/time.c b/commands/time/time.c similarity index 100% rename from commands/simple/time.c rename to commands/time/time.c diff --git a/commands/tinyhalt/Makefile b/commands/tinyhalt/Makefile new file mode 100644 index 000000000..afbe20a40 --- /dev/null +++ b/commands/tinyhalt/Makefile @@ -0,0 +1,11 @@ +# Makefile for tinyhalt + +.include + +PROG= halt +SRCS= tinyhalt.c +BINDIR= /bin +LINKS+= ${BINDIR}/halt ${BINDIR}/reboot +MAN= + +.include diff --git a/commands/tinyhalt/README b/commands/tinyhalt/README new file mode 100644 index 000000000..185fff020 --- /dev/null +++ b/commands/tinyhalt/README @@ -0,0 +1 @@ +See commands/reboot/README for more info. diff --git a/commands/reboot/tinyhalt.c b/commands/tinyhalt/tinyhalt.c similarity index 100% rename from commands/reboot/tinyhalt.c rename to commands/tinyhalt/tinyhalt.c diff --git a/commands/top/Makefile b/commands/top/Makefile new file mode 100644 index 000000000..1c3dfc815 --- /dev/null +++ b/commands/top/Makefile @@ -0,0 +1,9 @@ +PROG= top +CPPFLAGS+= -I${MINIXSRCDIR} -I${MINIXSRCDIR}/servers +BINMODE= 4755 +MAN= + +DPADD+= ${LIBCURSES} +LDADD+= -lcurses + +.include diff --git a/commands/simple/top.c b/commands/top/top.c similarity index 99% rename from commands/simple/top.c rename to commands/top/top.c index 9fa434b1d..f63d3bf68 100644 --- a/commands/simple/top.c +++ b/commands/top/top.c @@ -35,9 +35,9 @@ #include #include -#include "../../servers/pm/mproc.h" -#include "../../kernel/const.h" -#include "../../kernel/proc.h" +#include "pm/mproc.h" +#include "kernel/const.h" +#include "kernel/proc.h" u32_t system_hz; diff --git a/commands/touch/Makefile b/commands/touch/Makefile new file mode 100644 index 000000000..8c01abe2f --- /dev/null +++ b/commands/touch/Makefile @@ -0,0 +1,4 @@ +PROG= touch +MAN= + +.include diff --git a/commands/simple/touch.c b/commands/touch/touch.c similarity index 100% rename from commands/simple/touch.c rename to commands/touch/touch.c diff --git a/commands/tr/Makefile b/commands/tr/Makefile new file mode 100644 index 000000000..784afc309 --- /dev/null +++ b/commands/tr/Makefile @@ -0,0 +1,5 @@ +PROG= tr +SRCS= tr.c str.c +MAN= + +.include diff --git a/commands/simple/str.c b/commands/tr/str.c similarity index 100% rename from commands/simple/str.c rename to commands/tr/str.c diff --git a/commands/simple/tr.c b/commands/tr/tr.c similarity index 100% rename from commands/simple/tr.c rename to commands/tr/tr.c diff --git a/commands/simple/tr.h b/commands/tr/tr.h similarity index 100% rename from commands/simple/tr.h rename to commands/tr/tr.h diff --git a/commands/truncate/Makefile b/commands/truncate/Makefile new file mode 100644 index 000000000..5529a97dc --- /dev/null +++ b/commands/truncate/Makefile @@ -0,0 +1,4 @@ +PROG= truncate +MAN= + +.include diff --git a/commands/simple/truncate.c b/commands/truncate/truncate.c similarity index 100% rename from commands/simple/truncate.c rename to commands/truncate/truncate.c diff --git a/commands/tsort/Makefile b/commands/tsort/Makefile new file mode 100644 index 000000000..861bc368a --- /dev/null +++ b/commands/tsort/Makefile @@ -0,0 +1,4 @@ +PROG= tsort +MAN= + +.include diff --git a/commands/simple/tsort.c b/commands/tsort/tsort.c similarity index 100% rename from commands/simple/tsort.c rename to commands/tsort/tsort.c diff --git a/commands/ttt/Makefile b/commands/ttt/Makefile new file mode 100644 index 000000000..63c463c3d --- /dev/null +++ b/commands/ttt/Makefile @@ -0,0 +1,4 @@ +PROG= ttt +MAN= + +.include diff --git a/commands/simple/ttt.c b/commands/ttt/ttt.c similarity index 100% rename from commands/simple/ttt.c rename to commands/ttt/ttt.c diff --git a/commands/tty/Makefile b/commands/tty/Makefile new file mode 100644 index 000000000..165e296a6 --- /dev/null +++ b/commands/tty/Makefile @@ -0,0 +1,4 @@ +PROG= tty +MAN= + +.include diff --git a/commands/simple/tty.c b/commands/tty/tty.c similarity index 100% rename from commands/simple/tty.c rename to commands/tty/tty.c diff --git a/commands/udpstat/Makefile b/commands/udpstat/Makefile new file mode 100644 index 000000000..1738ca3ac --- /dev/null +++ b/commands/udpstat/Makefile @@ -0,0 +1,5 @@ +PROG= udpstat +CPPFLAGS+= -I${MINIXSRCDIR}/servers +MAN= + +.include diff --git a/commands/simple/udpstat.c b/commands/udpstat/udpstat.c similarity index 100% rename from commands/simple/udpstat.c rename to commands/udpstat/udpstat.c diff --git a/commands/umount/Makefile b/commands/umount/Makefile new file mode 100644 index 000000000..61e13d103 --- /dev/null +++ b/commands/umount/Makefile @@ -0,0 +1,6 @@ +PROG= umount +BINDIR= /bin +BINMODE= 4755 +MAN= + +.include diff --git a/commands/simple/umount.c b/commands/umount/umount.c similarity index 100% rename from commands/simple/umount.c rename to commands/umount/umount.c diff --git a/commands/uname/Makefile b/commands/uname/Makefile new file mode 100644 index 000000000..2f82adc10 --- /dev/null +++ b/commands/uname/Makefile @@ -0,0 +1,6 @@ +PROG= uname +MAN= + +LINKS+= ${BINDIR}/uname ${BINDIR}/arch + +.include diff --git a/commands/simple/uname.c b/commands/uname/uname.c similarity index 100% rename from commands/simple/uname.c rename to commands/uname/uname.c diff --git a/commands/unexpand/Makefile b/commands/unexpand/Makefile new file mode 100644 index 000000000..eb2a26f78 --- /dev/null +++ b/commands/unexpand/Makefile @@ -0,0 +1,4 @@ +PROG= unexpand +MAN= + +.include diff --git a/commands/simple/unexpand.c b/commands/unexpand/unexpand.c similarity index 100% rename from commands/simple/unexpand.c rename to commands/unexpand/unexpand.c diff --git a/commands/uniq/Makefile b/commands/uniq/Makefile new file mode 100644 index 000000000..b560bc694 --- /dev/null +++ b/commands/uniq/Makefile @@ -0,0 +1,4 @@ +PROG= uniq +MAN= + +.include diff --git a/commands/simple/uniq.c b/commands/uniq/uniq.c similarity index 100% rename from commands/simple/uniq.c rename to commands/uniq/uniq.c diff --git a/commands/unstack/Makefile b/commands/unstack/Makefile new file mode 100644 index 000000000..d6130f1e2 --- /dev/null +++ b/commands/unstack/Makefile @@ -0,0 +1,4 @@ +SCRIPTS= unstack.sh +MAN= + +.include diff --git a/commands/scripts/unstack.sh b/commands/unstack/unstack.sh similarity index 100% rename from commands/scripts/unstack.sh rename to commands/unstack/unstack.sh diff --git a/commands/update/Makefile b/commands/update/Makefile new file mode 100644 index 000000000..b2f27d608 --- /dev/null +++ b/commands/update/Makefile @@ -0,0 +1,4 @@ +PROG= update +MAN= + +.include diff --git a/commands/simple/update.c b/commands/update/update.c similarity index 100% rename from commands/simple/update.c rename to commands/update/update.c diff --git a/commands/urlget/Makefile b/commands/urlget/Makefile index c8cb04449..d1a69bcd8 100644 --- a/commands/urlget/Makefile +++ b/commands/urlget/Makefile @@ -3,34 +3,10 @@ # 07/02/96 Initial Release Michael Temari, # -CFLAGS= -D_MINIX $(OPT) -LDFLAGS=-fnone -BINDIR= /usr/bin PROG= urlget -LINK1= httpget -LINK2= ftpget -CC=exec cc +SRCS= urlget.c net.c +LINKS+= ${BINDIR}/urlget ${BINDIR}/httpget +LINKS+= ${BINDIR}/urlget ${BINDIR}/ftpget +MAN= -OBJS= urlget.o net.o - -all: $(PROG) - -$(PROG): $(OBJS) - $(CC) $(LDFLAGS) -o $@ $(OBJS) - install -S 4kw $@ - -clean: - rm -f $(PROG) $(OBJS) - -tar: - tar cvf urlget.tar Makefile urlget.c net.c net.h - -install: $(BINDIR)/$(PROG) $(BINDIR)/$(LINK1) $(BINDIR)/$(LINK2) - -$(BINDIR)/$(PROG): $(PROG) - install -c $? $@ - -$(BINDIR)/$(LINK1) $(BINDIR)/$(LINK2): $(BINDIR)/$(PROG) - install -l h $? $@ - -$(OBJS): net.h +.include diff --git a/commands/urlget/build b/commands/urlget/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/urlget/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/uud/Makefile b/commands/uud/Makefile new file mode 100644 index 000000000..4a6fd7d79 --- /dev/null +++ b/commands/uud/Makefile @@ -0,0 +1,6 @@ +PROG= uud +MAN= + +LINKS+= ${BINDIR}/uud ${BINDIR}/uudecode + +.include diff --git a/commands/simple/uud.c b/commands/uud/uud.c similarity index 100% rename from commands/simple/uud.c rename to commands/uud/uud.c diff --git a/commands/uue/Makefile b/commands/uue/Makefile new file mode 100644 index 000000000..bfaeddc78 --- /dev/null +++ b/commands/uue/Makefile @@ -0,0 +1,6 @@ +PROG= uue +MAN= + +LINKS+= ${BINDIR}/uue ${BINDIR}/uuencode + +.include diff --git a/commands/simple/uue.c b/commands/uue/uue.c similarity index 100% rename from commands/simple/uue.c rename to commands/uue/uue.c diff --git a/commands/version/Makefile b/commands/version/Makefile new file mode 100644 index 000000000..a9c0c4bae --- /dev/null +++ b/commands/version/Makefile @@ -0,0 +1,4 @@ +SCRIPTS= version.sh +MAN= + +.include diff --git a/commands/scripts/version.sh b/commands/version/version.sh similarity index 100% rename from commands/scripts/version.sh rename to commands/version/version.sh diff --git a/commands/vol/Makefile b/commands/vol/Makefile new file mode 100644 index 000000000..81616a30f --- /dev/null +++ b/commands/vol/Makefile @@ -0,0 +1,4 @@ +PROG= vol +MAN= + +.include diff --git a/commands/simple/vol.c b/commands/vol/vol.c similarity index 100% rename from commands/simple/vol.c rename to commands/vol/vol.c diff --git a/commands/wc/Makefile b/commands/wc/Makefile new file mode 100644 index 000000000..4a6b22683 --- /dev/null +++ b/commands/wc/Makefile @@ -0,0 +1,4 @@ +PROG= wc +MAN= + +.include diff --git a/commands/simple/wc.c b/commands/wc/wc.c similarity index 100% rename from commands/simple/wc.c rename to commands/wc/wc.c diff --git a/commands/whatis/Makefile b/commands/whatis/Makefile new file mode 100644 index 000000000..f01bac7fe --- /dev/null +++ b/commands/whatis/Makefile @@ -0,0 +1,6 @@ +SCRIPTS= whatis.sh +MAN= + +LINKS+= ${BINDIR}/whatis ${BINDIR}/apropos + +.include diff --git a/commands/scripts/whatis.sh b/commands/whatis/whatis.sh old mode 100755 new mode 100644 similarity index 100% rename from commands/scripts/whatis.sh rename to commands/whatis/whatis.sh diff --git a/commands/whereis/Makefile b/commands/whereis/Makefile new file mode 100644 index 000000000..744b2abc8 --- /dev/null +++ b/commands/whereis/Makefile @@ -0,0 +1,4 @@ +SCRIPTS= whereis.sh +MAN= + +.include diff --git a/commands/scripts/whereis.sh b/commands/whereis/whereis.sh old mode 100755 new mode 100644 similarity index 100% rename from commands/scripts/whereis.sh rename to commands/whereis/whereis.sh diff --git a/commands/which/Makefile b/commands/which/Makefile new file mode 100644 index 000000000..fb269d0d9 --- /dev/null +++ b/commands/which/Makefile @@ -0,0 +1,4 @@ +PROG= which +MAN= + +.include diff --git a/commands/simple/which.c b/commands/which/which.c similarity index 100% rename from commands/simple/which.c rename to commands/which/which.c diff --git a/commands/who/Makefile b/commands/who/Makefile new file mode 100644 index 000000000..f4e6363fd --- /dev/null +++ b/commands/who/Makefile @@ -0,0 +1,4 @@ +PROG= who +MAN= + +.include diff --git a/commands/simple/who.c b/commands/who/who.c similarity index 100% rename from commands/simple/who.c rename to commands/who/who.c diff --git a/commands/whoami/Makefile b/commands/whoami/Makefile new file mode 100644 index 000000000..afc37c837 --- /dev/null +++ b/commands/whoami/Makefile @@ -0,0 +1,4 @@ +PROG= whoami +MAN= + +.include diff --git a/commands/simple/whoami.c b/commands/whoami/whoami.c similarity index 100% rename from commands/simple/whoami.c rename to commands/whoami/whoami.c diff --git a/commands/write/Makefile b/commands/write/Makefile new file mode 100644 index 000000000..c0dbac142 --- /dev/null +++ b/commands/write/Makefile @@ -0,0 +1,6 @@ +PROG= write +BINGRP= tty +BINMODE= 2755 +MAN= + +.include diff --git a/commands/simple/write.c b/commands/write/write.c similarity index 100% rename from commands/simple/write.c rename to commands/write/write.c diff --git a/commands/writeisofs/Makefile b/commands/writeisofs/Makefile new file mode 100644 index 000000000..b5bc18fa5 --- /dev/null +++ b/commands/writeisofs/Makefile @@ -0,0 +1,4 @@ +PROG= writeisofs +MAN= + +.include diff --git a/commands/simple/writeisofs.c b/commands/writeisofs/writeisofs.c similarity index 100% rename from commands/simple/writeisofs.c rename to commands/writeisofs/writeisofs.c diff --git a/commands/xargs/Makefile b/commands/xargs/Makefile new file mode 100644 index 000000000..1d9e69072 --- /dev/null +++ b/commands/xargs/Makefile @@ -0,0 +1,4 @@ +PROG= xargs +MAN= + +.include diff --git a/commands/simple/xargs.c b/commands/xargs/xargs.c similarity index 100% rename from commands/simple/xargs.c rename to commands/xargs/xargs.c diff --git a/commands/byacc/ACKNOWLEDGEMEN b/commands/yacc/ACKNOWLEDGEMENTS similarity index 100% rename from commands/byacc/ACKNOWLEDGEMEN rename to commands/yacc/ACKNOWLEDGEMENTS diff --git a/commands/yacc/Makefile b/commands/yacc/Makefile new file mode 100644 index 000000000..72617494a --- /dev/null +++ b/commands/yacc/Makefile @@ -0,0 +1,7 @@ +# $NetBSD: Makefile,v 1.8 2003/05/18 07:57:38 lukem Exp $ + +PROG= yacc +SRCS= closure.c error.c lalr.c lr0.c main.c mkpar.c output.c reader.c \ + skeleton.c symtab.c verbose.c warshall.c + +.include diff --git a/commands/byacc/NEW_FEATURES b/commands/yacc/NEW_FEATURES similarity index 100% rename from commands/byacc/NEW_FEATURES rename to commands/yacc/NEW_FEATURES diff --git a/commands/yacc/NOTES b/commands/yacc/NOTES new file mode 100644 index 000000000..6448920c2 --- /dev/null +++ b/commands/yacc/NOTES @@ -0,0 +1,21 @@ +$NetBSD: NOTES,v 1.3 1997/10/20 03:41:15 lukem Exp $ + +Berkeley Yacc reflects its origins. The reason so many routines +use exactly six register variables is that Berkeley Yacc was +developed on a VAX using PCC. PCC placed at most six variables +in registers. I went to considerable effort to find which six +variables most belonged in registers. Changes in machines and +compilers make that effort worthless, perhaps even harmful. + +[Given the previous paragraph, and the fact that GCC does not respect + register declarations, and the fact that much of the rest of the + 4.4lite2 release had "register" declarations extirpated, I've removed + most of the register declarations from the code. I left them in the + generated skeleton code "for the hell of it" but they probably should + go from there, too. -- pm, July 1997] + +[I totally removed the register stuff; we've deprecated it elsewhere + in the tree now -- lukem, October 1997] + +The code contains many instances where address calculations are +performed in particular ways to optimize the code for the VAX. diff --git a/commands/byacc/README b/commands/yacc/README similarity index 100% rename from commands/byacc/README rename to commands/yacc/README diff --git a/commands/byacc/closure.c b/commands/yacc/closure.c similarity index 55% rename from commands/byacc/closure.c rename to commands/yacc/closure.c index 7c8f95791..6361a2946 100644 --- a/commands/byacc/closure.c +++ b/commands/yacc/closure.c @@ -1,3 +1,46 @@ +/* $NetBSD: closure.c,v 1.8 2006/05/24 18:01:43 christos Exp $ */ + +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Robert Paul Corbett. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#if defined(__RCSID) && !defined(lint) +#if 0 +static char sccsid[] = "@(#)closure.c 5.3 (Berkeley) 5/24/93"; +#else +__RCSID("$NetBSD: closure.c,v 1.8 2006/05/24 18:01:43 christos Exp $"); +#endif +#endif /* not lint */ + #include "defs.h" short *itemset; @@ -7,15 +50,17 @@ unsigned *ruleset; static unsigned *first_derives; static unsigned *EFF; +static void set_EFF(void); -set_EFF() +static void +set_EFF(void) { - register unsigned *row; - register int symbol; - register short *sp; - register int rowsize; - register int i; - register int rule; + unsigned *row; + int symbol; + short *sp; + int rowsize; + int i; + int rule; rowsize = WORDSIZE(nvars); EFF = NEW2(nvars * rowsize, unsigned); @@ -44,20 +89,23 @@ set_EFF() } -set_first_derives() +void +set_first_derives(void) { - register unsigned *rrow; - register unsigned *vrow; - register int j; - register unsigned k; - register unsigned cword; - register short *rp; + unsigned *rrow; + unsigned *vrow; + int j; + unsigned k; + unsigned cword; + short *rp; int rule; int i; int rulesetsize; int varsetsize; + cword = 0; + rulesetsize = WORDSIZE(nrules); varsetsize = WORDSIZE(nvars); first_derives = NEW2(nvars * rulesetsize, unsigned) - ntokens * rulesetsize; @@ -99,17 +147,16 @@ set_first_derives() } -closure(nucleus, n) -short *nucleus; -int n; +void +closure(short *nucleus, int n) { - register int ruleno; - register unsigned word; - register unsigned i; - register short *csp; - register unsigned *dsp; - register unsigned *rsp; - register int rulesetsize; + int ruleno; + unsigned word; + unsigned i; + short *csp; + unsigned *dsp; + unsigned *rsp; + int rulesetsize; short *csend; unsigned *rsend; @@ -168,8 +215,8 @@ int n; } - -finalize_closure() +void +finalize_closure(void) { FREE(itemset); FREE(ruleset); @@ -179,10 +226,10 @@ finalize_closure() #ifdef DEBUG -print_closure(n) -int n; +void +print_closure(int n) { - register short *isp; + short *isp; printf("\n\nn = %d\n\n", n); for (isp = itemset; isp < itemsetend; isp++) @@ -190,12 +237,13 @@ int n; } -print_EFF() +void +print_EFF(void) { - register int i, j; - register unsigned *rowp; - register unsigned word; - register unsigned k; + int i, j; + unsigned *rowp; + unsigned word; + unsigned k; printf("\n\nEpsilon Free Firsts\n"); @@ -221,13 +269,14 @@ print_EFF() } -print_first_derives() +void +print_first_derives(void) { - register int i; - register int j; - register unsigned *rp; - register unsigned cword; - register unsigned k; + int i; + int j; + unsigned *rp; + unsigned cword; + unsigned k; printf("\n\n\nFirst Derives\n"); diff --git a/commands/byacc/defs.h b/commands/yacc/defs.h similarity index 54% rename from commands/byacc/defs.h rename to commands/yacc/defs.h index c8d517917..19b18b41e 100644 --- a/commands/byacc/defs.h +++ b/commands/yacc/defs.h @@ -1,6 +1,48 @@ +/* $NetBSD: defs.h,v 1.17 2009/04/14 09:41:30 lukem Exp $ */ + +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Robert Paul Corbett. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)defs.h 5.6 (Berkeley) 5/24/93 + */ + +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + #include #include #include +#include +#include /* machine-dependent definitions */ @@ -18,23 +60,14 @@ /* from r (0-indexed) */ /* SETBIT sets the n-th bit starting from r */ -#if !__STDC__ #define MAXCHAR 255 #define MAXSHORT 32767 #define MINSHORT -32768 -#define BITS_PER_WORD 32 -#else -#include -#define MAXCHAR UCHAR_MAX -#define MAXSHORT SHRT_MAX -#define MINSHORT SHRT_MIN -#define BITS_PER_WORD (INT_MAX == 32767 ? 16 : 32) -#define BITS_PER_BPW (INT_MAX == 32767 ? 4 : 5) -#endif #define MAXTABLE 32500 -#define WORDSIZE(n) (((n)+(BITS_PER_WORD-1))/BITS_PER_WORD) -#define BIT(r, n) ((((r)[(n)>>BITS_PER_BPW])>>((n)&(BITS_PER_WORD-1)))&1) -#define SETBIT(r, n) ((r)[(n)>>BITS_PER_BPW]|=((unsigned)1<<((n)&(BITS_PER_WORD-1)))) +#define BITS_PER_WORD 32 +#define WORDSIZE(n) (((n)+(BITS_PER_WORD-1)/BITS_PER_WORD)) +#define BIT(r, n) ((((r)[(n)>>5])>>((n)&31)&1)) +#define SETBIT(r, n) ((r)[(n)>>5]|=((unsigned)1<<((n)&31))) /* character names */ @@ -72,6 +105,7 @@ #define START 7 #define UNION 8 #define IDENT 9 +#define EXPECT 10 /* symbol classes */ @@ -192,24 +226,24 @@ extern char lflag; extern char rflag; extern char tflag; extern char vflag; -extern char *symbol_prefix; +extern const char *symbol_prefix; -extern char *myname; +extern const char *myname; extern char *cptr; extern char *line; extern int lineno; extern int outline; -extern char *banner[]; -extern char *tables[]; -extern char *header[]; -extern char *body[]; -extern char *trailer[]; +extern const char * const banner[]; +extern const char * const tables[]; +extern const char * const header[]; +extern const char * const body[]; +extern const char * const trailer[]; extern char *action_file_name; extern char *code_file_name; extern char *defines_file_name; -extern char *input_file_name; +extern const char *input_file_name; extern char *output_file_name; extern char *text_file_name; extern char *union_file_name; @@ -232,7 +266,6 @@ extern int nvars; extern int ntags; extern char unionized; -extern char line_format[]; extern int start_symbol; extern char **symbol_name; @@ -279,20 +312,61 @@ extern short final_state; /* global functions */ -extern char *allocate(); -extern bucket *lookup(); -extern bucket *make_bucket(); +extern char *allocate(unsigned); +extern bucket *lookup(char *); +extern bucket *make_bucket(const char *); +extern void set_first_derives(void); +extern void closure(short *, int); +extern void finalize_closure(void); -/* system variables */ +extern __dead void fatal(const char *); -extern int errno; +extern void reflexive_transitive_closure(unsigned *, int); +extern __dead void done(int); +extern __dead void no_space(void); +extern __dead void open_error(const char *); +extern __dead void unexpected_EOF(void); +extern void print_pos(char *, char *); +extern __dead void syntax_error(int, char *, char *); +extern __dead void unterminated_comment(int, char *, char *); +extern __dead void unterminated_string(int, char *, char *); +extern __dead void unterminated_text(int, char *, char *); +extern __dead void unterminated_union(int, char *, char *); +extern __dead void over_unionized(char *); +extern void illegal_tag(int, char *, char *); +extern void illegal_character(char *); +extern void used_reserved(char *); +extern void tokenized_start(char *); +extern void retyped_warning(char *); +extern void reprec_warning(char *); +extern void revalued_warning(char *); +extern __dead void terminal_start(char *); +extern void restarted_warning(void); +extern __dead void no_grammar(void); +extern __dead void terminal_lhs(int); +extern void prec_redeclared(void); +extern __dead void unterminated_action(int, char *, char *); +extern void dollar_warning(int, int); +extern __dead void dollar_error(int, char *, char *); +extern __dead void untyped_lhs(void); +extern __dead void untyped_rhs(int, char *); +extern __dead void unknown_rhs(int); +extern void default_action_warning(void); +extern __dead void undefined_goal(char *); +extern void undefined_symbol_warning(char *); -/* system functions */ +extern void lalr(void); -extern void free(); -extern char *calloc(); -extern char *malloc(); -extern char *realloc(); -extern char *strcpy(); +extern void reader(void); +extern void lr0(void); +extern void make_parser(void); +extern void verbose(void); +extern void output(void); +extern void free_parser(void); +extern void write_section(const char * const []); + +extern void create_symbol_table(void); +extern void free_symbol_table(void); +extern void free_symbols(void); diff --git a/commands/byacc/error.c b/commands/yacc/error.c similarity index 57% rename from commands/byacc/error.c rename to commands/yacc/error.c index 3ed564c62..29c79adf9 100644 --- a/commands/byacc/error.c +++ b/commands/yacc/error.c @@ -1,49 +1,89 @@ +/* $NetBSD: error.c,v 1.11 2009/04/14 09:41:30 lukem Exp $ */ + +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Robert Paul Corbett. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#if defined(__RCSID) && !defined(lint) +#if 0 +static char sccsid[] = "@(#)error.c 5.3 (Berkeley) 6/1/90"; +#else +__RCSID("$NetBSD: error.c,v 1.11 2009/04/14 09:41:30 lukem Exp $"); +#endif +#endif /* not lint */ + /* routines for printing error messages */ #include "defs.h" - -fatal(msg) -char *msg; +__dead void +fatal(const char *msg) { fprintf(stderr, "%s: f - %s\n", myname, msg); done(2); } -no_space() +__dead void +no_space(void) { fprintf(stderr, "%s: f - out of space\n", myname); done(2); } - -open_error(filename) -char *filename; +__dead void +open_error(const char *filename) { fprintf(stderr, "%s: f - cannot open \"%s\"\n", myname, filename); done(2); } - -unexpected_EOF() +__dead void +unexpected_EOF(void) { fprintf(stderr, "%s: e - line %d of \"%s\", unexpected end-of-file\n", myname, lineno, input_file_name); done(1); } - -print_pos(st_line, st_cptr) -char *st_line; -char *st_cptr; +void +print_pos(char *st_line, char *st_cptr) { - register char *s; + char *s; if (st_line == 0) return; for (s = st_line; *s != '\n'; ++s) { - if (isprint(*s) || *s == '\t') + if (isprint((unsigned char)*s) || *s == '\t') putc(*s, stderr); else putc('?', stderr); @@ -60,11 +100,8 @@ char *st_cptr; putc('\n', stderr); } - -syntax_error(st_lineno, st_line, st_cptr) -int st_lineno; -char *st_line; -char *st_cptr; +__dead void +syntax_error(int st_lineno, char *st_line, char *st_cptr) { fprintf(stderr, "%s: e - line %d of \"%s\", syntax error\n", myname, st_lineno, input_file_name); @@ -72,11 +109,8 @@ char *st_cptr; done(1); } - -unterminated_comment(c_lineno, c_line, c_cptr) -int c_lineno; -char *c_line; -char *c_cptr; +__dead void +unterminated_comment(int c_lineno, char *c_line, char *c_cptr) { fprintf(stderr, "%s: e - line %d of \"%s\", unmatched /*\n", myname, c_lineno, input_file_name); @@ -84,11 +118,8 @@ char *c_cptr; done(1); } - -unterminated_string(s_lineno, s_line, s_cptr) -int s_lineno; -char *s_line; -char *s_cptr; +__dead void +unterminated_string(int s_lineno, char *s_line, char *s_cptr) { fprintf(stderr, "%s: e - line %d of \"%s\", unterminated string\n", myname, s_lineno, input_file_name); @@ -96,11 +127,8 @@ char *s_cptr; done(1); } - -unterminated_text(t_lineno, t_line, t_cptr) -int t_lineno; -char *t_line; -char *t_cptr; +__dead void +unterminated_text(int t_lineno, char *t_line, char *t_cptr) { fprintf(stderr, "%s: e - line %d of \"%s\", unmatched %%{\n", myname, t_lineno, input_file_name); @@ -108,11 +136,8 @@ char *t_cptr; done(1); } - -unterminated_union(u_lineno, u_line, u_cptr) -int u_lineno; -char *u_line; -char *u_cptr; +__dead void +unterminated_union(int u_lineno, char *u_line, char *u_cptr) { fprintf(stderr, "%s: e - line %d of \"%s\", unterminated %%union \ declaration\n", myname, u_lineno, input_file_name); @@ -120,9 +145,8 @@ declaration\n", myname, u_lineno, input_file_name); done(1); } - -over_unionized(u_cptr) -char *u_cptr; +__dead void +over_unionized(char *u_cptr) { fprintf(stderr, "%s: e - line %d of \"%s\", too many %%union \ declarations\n", myname, lineno, input_file_name); @@ -130,11 +154,8 @@ declarations\n", myname, lineno, input_file_name); done(1); } - -illegal_tag(t_lineno, t_line, t_cptr) -int t_lineno; -char *t_line; -char *t_cptr; +__dead void +illegal_tag(int t_lineno, char *t_line, char *t_cptr) { fprintf(stderr, "%s: e - line %d of \"%s\", illegal tag\n", myname, t_lineno, input_file_name); @@ -142,9 +163,8 @@ char *t_cptr; done(1); } - -illegal_character(c_cptr) -char *c_cptr; +__dead void +illegal_character(char *c_cptr) { fprintf(stderr, "%s: e - line %d of \"%s\", illegal character\n", myname, lineno, input_file_name); @@ -152,93 +172,83 @@ char *c_cptr; done(1); } - -used_reserved(s) -char *s; +__dead void +used_reserved(char *s) { fprintf(stderr, "%s: e - line %d of \"%s\", illegal use of reserved symbol \ %s\n", myname, lineno, input_file_name, s); done(1); } - -tokenized_start(s) -char *s; +__dead void +tokenized_start(char *s) { fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s cannot be \ declared to be a token\n", myname, lineno, input_file_name, s); done(1); } - -retyped_warning(s) -char *s; +void +retyped_warning(char *s) { fprintf(stderr, "%s: w - line %d of \"%s\", the type of %s has been \ redeclared\n", myname, lineno, input_file_name, s); } - -reprec_warning(s) -char *s; +void +reprec_warning(char *s) { fprintf(stderr, "%s: w - line %d of \"%s\", the precedence of %s has been \ redeclared\n", myname, lineno, input_file_name, s); } - -revalued_warning(s) -char *s; +void +revalued_warning(char *s) { fprintf(stderr, "%s: w - line %d of \"%s\", the value of %s has been \ redeclared\n", myname, lineno, input_file_name, s); } - -terminal_start(s) -char *s; +__dead void +terminal_start(char *s) { fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s is a \ token\n", myname, lineno, input_file_name, s); done(1); } - -restarted_warning() +void +restarted_warning(void) { fprintf(stderr, "%s: w - line %d of \"%s\", the start symbol has been \ redeclared\n", myname, lineno, input_file_name); } - -no_grammar() +__dead void +no_grammar(void) { fprintf(stderr, "%s: e - line %d of \"%s\", no grammar has been \ specified\n", myname, lineno, input_file_name); done(1); } - -terminal_lhs(s_lineno) -int s_lineno; +__dead void +terminal_lhs(int s_lineno) { fprintf(stderr, "%s: e - line %d of \"%s\", a token appears on the lhs \ of a production\n", myname, s_lineno, input_file_name); done(1); } - -prec_redeclared() +void +prec_redeclared(void) { fprintf(stderr, "%s: w - line %d of \"%s\", conflicting %%prec \ specifiers\n", myname, lineno, input_file_name); } - -unterminated_action(a_lineno, a_line, a_cptr) -int a_lineno; -char *a_line; -char *a_cptr; +__dead void +unterminated_action(int a_lineno, char *a_line, char *a_cptr) { fprintf(stderr, "%s: e - line %d of \"%s\", unterminated action\n", myname, a_lineno, input_file_name); @@ -246,20 +256,15 @@ char *a_cptr; done(1); } - -dollar_warning(a_lineno, i) -int a_lineno; -int i; +void +dollar_warning(int a_lineno, int i) { fprintf(stderr, "%s: w - line %d of \"%s\", $%d references beyond the \ end of the current rule\n", myname, a_lineno, input_file_name, i); } - -dollar_error(a_lineno, a_line, a_cptr) -int a_lineno; -char *a_line; -char *a_cptr; +__dead void +dollar_error(int a_lineno, char *a_line, char *a_cptr) { fprintf(stderr, "%s: e - line %d of \"%s\", illegal $-name\n", myname, a_lineno, input_file_name); @@ -267,51 +272,46 @@ char *a_cptr; done(1); } - -untyped_lhs() +__dead void +untyped_lhs(void) { fprintf(stderr, "%s: e - line %d of \"%s\", $$ is untyped\n", myname, lineno, input_file_name); done(1); } - -untyped_rhs(i, s) -int i; -char *s; +__dead void +untyped_rhs(int i, char *s) { fprintf(stderr, "%s: e - line %d of \"%s\", $%d (%s) is untyped\n", myname, lineno, input_file_name, i, s); done(1); } - -unknown_rhs(i) -int i; +__dead void +unknown_rhs(int i) { fprintf(stderr, "%s: e - line %d of \"%s\", $%d is untyped\n", myname, lineno, input_file_name, i); done(1); } - -default_action_warning() +void +default_action_warning(void) { fprintf(stderr, "%s: w - line %d of \"%s\", the default action assigns an \ undefined value to $$\n", myname, lineno, input_file_name); } - -undefined_goal(s) -char *s; +__dead void +undefined_goal(char *s) { fprintf(stderr, "%s: e - the start symbol %s is undefined\n", myname, s); done(1); } - -undefined_symbol_warning(s) -char *s; +void +undefined_symbol_warning(char *s) { fprintf(stderr, "%s: w - the symbol %s is undefined\n", myname, s); } diff --git a/commands/byacc/lalr.c b/commands/yacc/lalr.c similarity index 65% rename from commands/byacc/lalr.c rename to commands/yacc/lalr.c index 640ddc4ca..54b7e82ab 100644 --- a/commands/byacc/lalr.c +++ b/commands/yacc/lalr.c @@ -1,3 +1,46 @@ +/* $NetBSD: lalr.c,v 1.11 2009/04/14 09:41:30 lukem Exp $ */ + +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Robert Paul Corbett. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#if defined(__RCSID) && !defined(lint) +#if 0 +static char sccsid[] = "@(#)lalr.c 5.3 (Berkeley) 6/1/90"; +#else +__RCSID("$NetBSD: lalr.c,v 1.11 2009/04/14 09:41:30 lukem Exp $"); +#endif +#endif /* not lint */ + #include "defs.h" typedef @@ -8,7 +51,6 @@ typedef } shorts; -int tokensetsize; short *lookaheads; short *LAruleno; unsigned *LA; @@ -20,7 +62,26 @@ short *goto_map; short *from_state; short *to_state; -short **transpose(); +static int tokensetsize; + +static short **transpose(short **, int); +static void set_state_table(void); +static void set_accessing_symbol(void); +static void set_shift_table(void); +static void set_reduction_table(void); +static void set_maxrhs(void); +static void initialize_LA(void); +static void set_goto_map(void); +static void initialize_F(void); +static void build_relations(void); +static void compute_FOLLOWS(void); +static void compute_lookaheads(void); + +static int map_goto(int, int); +static void digraph(short **); +static void add_lookback_edge(int, int, int); +static void traverse(int); + static int infinity; static int maxrhs; @@ -33,8 +94,8 @@ static short *INDEX; static short *VERTICES; static int top; - -lalr() +void +lalr(void) { tokensetsize = WORDSIZE(ntokens); @@ -52,10 +113,10 @@ lalr() } - -set_state_table() +static void +set_state_table(void) { - register core *sp; + core *sp; state_table = NEW2(nstates, core *); for (sp = first_state; sp; sp = sp->next) @@ -63,10 +124,10 @@ set_state_table() } - -set_accessing_symbol() +static void +set_accessing_symbol(void) { - register core *sp; + core *sp; accessing_symbol = NEW2(nstates, short); for (sp = first_state; sp; sp = sp->next) @@ -74,10 +135,10 @@ set_accessing_symbol() } - -set_shift_table() +static void +set_shift_table(void) { - register shifts *sp; + shifts *sp; shift_table = NEW2(nstates, shifts *); for (sp = first_shift; sp; sp = sp->next) @@ -85,10 +146,10 @@ set_shift_table() } - -set_reduction_table() +static void +set_reduction_table(void) { - register reductions *rp; + reductions *rp; reduction_table = NEW2(nstates, reductions *); for (rp = first_reduction; rp; rp = rp->next) @@ -96,13 +157,13 @@ set_reduction_table() } - -set_maxrhs() +static void +set_maxrhs(void) { - register short *itemp; - register short *item_end; - register int length; - register int max; + short *itemp; + short *item_end; + int length; + int max; length = 0; max = 0; @@ -124,11 +185,11 @@ set_maxrhs() } - -initialize_LA() +static void +initialize_LA(void) { - register int i, j, k; - register reductions *rp; + int i, j, k; + reductions *rp; lookaheads = NEW2(nstates + 1, short); @@ -162,15 +223,16 @@ initialize_LA() } -set_goto_map() +static void +set_goto_map(void) { - register shifts *sp; - register int i; - register int symbol; - register int k; - register short *temp_map; - register int state2; - register int state1; + shifts *sp; + int i; + int symbol; + int k; + short *temp_map; + int state2; + int state1; goto_map = NEW2(nvars + 1, short) - ntokens; temp_map = NEW2(nvars + 1, short) - ntokens; @@ -231,15 +293,13 @@ set_goto_map() /* Map_goto maps a state/symbol pair into its numeric representation. */ -int -map_goto(state, symbol) -int state; -int symbol; +static int +map_goto(int state, int symbol) { - register int high; - register int low; - register int middle; - register int s; + int high; + int low; + int middle; + int s; low = goto_map[symbol]; high = goto_map[symbol + 1]; @@ -259,21 +319,21 @@ int symbol; } - -initialize_F() +static void +initialize_F(void) { - register int i; - register int j; - register int k; - register shifts *sp; - register short *edge; - register unsigned *rowp; - register short *rp; - register short **reads; - register int nedges; - register int stateno; - register int symbol; - register int nwords; + int i; + int j; + int k; + shifts *sp; + short *edge; + unsigned *rowp; + short *rp; + short **reads; + int nedges; + int stateno; + int symbol; + int nwords; nwords = ngotos * tokensetsize; F = NEW2(nwords, unsigned); @@ -336,26 +396,26 @@ initialize_F() } - -build_relations() +static void +build_relations(void) { - register int i; - register int j; - register int k; - register short *rulep; - register short *rp; - register shifts *sp; - register int length; - register int nedges; - register int done; - register int state1; - register int stateno; - register int symbol1; - register int symbol2; - register short *shortp; - register short *edge; - register short *states; - register short **new_includes; + int i; + int j; + int k; + short *rulep; + short *rp; + shifts *sp; + int length; + int nedges; + int isdone; + int state1; + int stateno; + int symbol1; + int symbol2; + short *shortp; + short *edge; + short *states; + short **new_includes; includes = NEW2(ngotos, short *); edge = NEW2(ngotos + 1, short); @@ -391,16 +451,16 @@ build_relations() add_lookback_edge(stateno, *rulep, i); length--; - done = 0; - while (!done) + isdone = 0; + while (!isdone) { - done = 1; + isdone = 1; rp--; if (ISVAR(*rp)) { stateno = states[--length]; edge[nedges++] = map_goto(stateno, *rp); - if (nullable[*rp] && length > 0) done = 0; + if (nullable[*rp] && length > 0) isdone = 0; } } } @@ -429,12 +489,12 @@ build_relations() } -add_lookback_edge(stateno, ruleno, gotono) -int stateno, ruleno, gotono; +static void +add_lookback_edge(int stateno, int ruleno, int gotono) { - register int i, k; - register int found; - register shorts *sp; + int i, k; + int found; + shorts *sp; i = lookaheads[stateno]; k = lookaheads[stateno + 1]; @@ -456,23 +516,21 @@ int stateno, ruleno, gotono; -short ** -transpose(R, n) -short **R; -int n; +static short ** +transpose(short **tR, int n) { - register short **new_R; - register short **temp_R; - register short *nedges; - register short *sp; - register int i; - register int k; + short **new_R; + short **temp_R; + short *nedges; + short *sp; + int i; + int k; nedges = NEW2(n, short); for (i = 0; i < n; i++) { - sp = R[i]; + sp = tR[i]; if (sp) { while (*sp >= 0) @@ -499,7 +557,7 @@ int n; for (i = 0; i < n; i++) { - sp = R[i]; + sp = tR[i]; if (sp) { while (*sp >= 0) @@ -513,19 +571,20 @@ int n; } - -compute_FOLLOWS() +static void +compute_FOLLOWS(void) { digraph(includes); } -compute_lookaheads() +static void +compute_lookaheads(void) { - register int i, n; - register unsigned *fp1, *fp2, *fp3; - register shorts *sp, *next; - register unsigned *rowp; + int i, n; + unsigned *fp1, *fp2, *fp3; + shorts *sp, *next; + unsigned *rowp; rowp = LA; n = lookaheads[nstates]; @@ -554,10 +613,10 @@ compute_lookaheads() } -digraph(relation) -short **relation; +static void +digraph(short **relation) { - register int i; + int i; infinity = ngotos + 2; INDEX = NEW2(ngotos + 1, short); @@ -580,15 +639,14 @@ short **relation; } - -traverse(i) -register int i; +static void +traverse(int i) { - register unsigned *fp1; - register unsigned *fp2; - register unsigned *fp3; - register int j; - register short *rp; + unsigned *fp1; + unsigned *fp2; + unsigned *fp3; + int j; + short *rp; int height; unsigned *base; diff --git a/commands/byacc/lr0.c b/commands/yacc/lr0.c similarity index 65% rename from commands/byacc/lr0.c rename to commands/yacc/lr0.c index 3ee42a884..7bdfb7ac3 100644 --- a/commands/byacc/lr0.c +++ b/commands/yacc/lr0.c @@ -1,3 +1,45 @@ +/* $NetBSD: lr0.c,v 1.10 2009/04/14 09:41:30 lukem Exp $ */ + +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Robert Paul Corbett. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#if defined(__RCSID) && !defined(lint) +#if 0 +static char sccsid[] = "@(#)lr0.c 5.3 (Berkeley) 1/20/91"; +#else +__RCSID("$NetBSD: lr0.c,v 1.10 2009/04/14 09:41:30 lukem Exp $"); +#endif +#endif /* not lint */ #include "defs.h" @@ -10,8 +52,31 @@ core *first_state; shifts *first_shift; reductions *first_reduction; -int get_state(); -core *new_state(); +static int get_state(int); +static core *new_state(int); + +static void allocate_itemsets(void); +static void allocate_storage(void); +static void append_states(void); +static void free_storage(void); +static void generate_states(void); +static void initialize_states(void); +static void new_itemsets(void); +#ifdef DEBUG +static void show_cores(void); +static void show_ritems(void); +static void show_rrhs(void); +static void show_shifts(void); +#endif +static void save_shifts(void); +static void save_reductions(void); +static void set_derives(void); +static void set_nullable(void); +#ifdef DEBUG +static void print_derives(void); +static void free_derives(void); +static void free_nullable(void); +#endif static core **state_set; static core *this_state; @@ -29,16 +94,16 @@ static short **kernel_base; static short **kernel_end; static short *kernel_items; - -allocate_itemsets() +static void +allocate_itemsets(void) { - register short *itemp; - register short *item_end; - register int symbol; - register int i; - register int count; - register int max; - register short *symbol_count; + short *itemp; + short *item_end; + int symbol; + int i; + int count; + int max; + short *symbol_count; count = 0; symbol_count = NEW2(nsyms, short); @@ -71,8 +136,8 @@ allocate_itemsets() kernel_end = NEW2(nsyms, short *); } - -allocate_storage() +static void +allocate_storage(void) { allocate_itemsets(); shiftset = NEW2(nsyms, short); @@ -80,12 +145,12 @@ allocate_storage() state_set = NEW2(nitems, core *); } - -append_states() +static void +append_states(void) { - register int i; - register int j; - register int symbol; + int i; + int j; + int symbol; #ifdef TRACE fprintf(stderr, "Entering append_states()\n"); @@ -109,8 +174,8 @@ append_states() } } - -free_storage() +static void +free_storage(void) { FREE(shift_symbol); FREE(redset); @@ -122,8 +187,8 @@ free_storage() } - -generate_states() +static void +generate_states(void) { allocate_storage(); itemset = NEW2(nitems, short); @@ -150,17 +215,16 @@ generate_states() -int -get_state(symbol) -int symbol; +static int +get_state(int symbol) { - register int key; - register short *isp1; - register short *isp2; - register short *iend; - register core *sp; - register int found; - register int n; + int key; + short *isp1; + short *isp2; + short *iend; + core *sp; + int found; + int n; #ifdef TRACE fprintf(stderr, "Entering get_state(%d)\n", symbol); @@ -214,12 +278,12 @@ int symbol; } - -initialize_states() +static void +initialize_states(void) { - register int i; - register short *start_derives; - register core *p; + int i; + short *start_derives; + core *p; start_derives = derives[start_symbol]; for (i = 0; start_derives[i] >= 0; ++i) @@ -242,13 +306,14 @@ initialize_states() } -new_itemsets() +static void +new_itemsets(void) { - register int i; - register int shiftcount; - register short *isp; - register short *ksp; - register int symbol; + int i; + int shiftcount; + short *isp; + short *ksp; + int symbol; for (i = 0; i < nsyms; i++) kernel_end[i] = 0; @@ -278,15 +343,14 @@ new_itemsets() -core * -new_state(symbol) -int symbol; +static core * +new_state(int symbol) { - register int n; - register core *p; - register short *isp1; - register short *isp2; - register short *iend; + int n; + core *p; + short *isp1; + short *isp2; + short *iend; #ifdef TRACE fprintf(stderr, "Entering new_state(%d)\n", symbol); @@ -316,10 +380,10 @@ int symbol; return (p); } - +#ifdef DEBUG /* show_cores is used for debugging */ - -show_cores() +static void +show_cores(void) { core *p; int i, j, k, n; @@ -353,8 +417,8 @@ show_cores() /* show_ritems is used for debugging */ - -show_ritems() +static void +show_ritems(void) { int i; @@ -364,7 +428,8 @@ show_ritems() /* show_rrhs is used for debugging */ -show_rrhs() +static void +show_rrhs(void) { int i; @@ -374,8 +439,8 @@ show_rrhs() /* show_shifts is used for debugging */ - -show_shifts() +static void +show_shifts(void) { shifts *p; int i, j, k; @@ -391,14 +456,16 @@ show_shifts() printf("\t%d\n", p->shift[i]); } } +#endif -save_shifts() +static void +save_shifts(void) { - register shifts *p; - register short *sp1; - register short *sp2; - register short *send; + shifts *p; + short *sp1; + short *sp2; + short *send; p = (shifts *) allocate((unsigned) (sizeof(shifts) + (nshifts - 1) * sizeof(short))); @@ -426,16 +493,16 @@ save_shifts() } - -save_reductions() +static void +save_reductions(void) { - register short *isp; - register short *rp1; - register short *rp2; - register int item; - register int count; - register reductions *p; - register short *rend; + short *isp; + short *rp1; + short *rp2; + int item; + int count; + reductions *p; + short *rend; count = 0; for (isp = itemset; isp < itemsetend; isp++) @@ -476,13 +543,17 @@ save_reductions() } -set_derives() +static void +set_derives(void) { - register int i, k; - register int lhs; - register short *rules; + int i, k; + int lhs; + short *rules; derives = NEW2(nsyms, short *); + if (start_symbol >= nsyms) + return; + rules = NEW2(nvars + nrules, short); k = 0; @@ -506,17 +577,21 @@ set_derives() #endif } -free_derives() +#ifdef DEBUG +static void +free_derives(void) { FREE(derives[start_symbol]); FREE(derives); } +#endif #ifdef DEBUG -print_derives() +static void +print_derives(void) { - register int i; - register short *sp; + int i; + short *sp; printf("\nDERIVES\n\n"); @@ -535,11 +610,12 @@ print_derives() #endif -set_nullable() +static void +set_nullable(void) { - register int i, j; - register int empty; - int done; + int i, j; + int empty; + int isdone; nullable = MALLOC(nsyms); if (nullable == 0) no_space(); @@ -547,10 +623,10 @@ set_nullable() for (i = 0; i < nsyms; ++i) nullable[i] = 0; - done = 0; - while (!done) + isdone = 0; + while (!isdone) { - done = 1; + isdone = 1; for (i = 1; i < nitems; i++) { empty = 1; @@ -566,7 +642,7 @@ set_nullable() if (!nullable[j]) { nullable[j] = 1; - done = 0; + isdone = 0; } } } @@ -584,13 +660,17 @@ set_nullable() } -free_nullable() +#ifdef DEBUG +static void +free_nullable(void) { FREE(nullable); } +#endif -lr0() +void +lr0(void) { set_derives(); set_nullable(); diff --git a/commands/yacc/main.c b/commands/yacc/main.c new file mode 100644 index 000000000..0d529a857 --- /dev/null +++ b/commands/yacc/main.c @@ -0,0 +1,484 @@ +/* $NetBSD: main.c,v 1.21 2009/04/14 09:41:30 lukem Exp $ */ + +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Robert Paul Corbett. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + +#include +#if defined(__COPYRIGHT) && !defined(lint) +__COPYRIGHT("@(#) Copyright (c) 1989\ + The Regents of the University of California. All rights reserved."); +#endif /* not lint */ + +#if defined(__RCSID) && !defined(lint) +#if 0 +static char sccsid[] = "@(#)main.c 5.5 (Berkeley) 5/24/93"; +#else +__RCSID("$NetBSD: main.c,v 1.21 2009/04/14 09:41:30 lukem Exp $"); +#endif +#endif /* not lint */ + +#include +#include +#include +#include "defs.h" + +char dflag; +char lflag; +char rflag; +char tflag; +char vflag; + +const char *symbol_prefix; +const char *myname = "yacc"; + + +int lineno; +int outline; + +char *action_file_name; +char *code_file_name; +char *defines_file_name; +const char *input_file_name = ""; +char *output_file_name; +char *text_file_name; +char *union_file_name; +char *verbose_file_name; + +FILE *action_file; /* a temp file, used to save actions associated */ + /* with rules until the parser is written */ +FILE *code_file; /* y.code.c (used when the -r option is specified) */ +FILE *defines_file; /* y.tab.h */ +FILE *input_file; /* the input file */ +FILE *output_file; /* y.tab.c */ +FILE *text_file; /* a temp file, used to save text until all */ + /* symbols have been defined */ +FILE *union_file; /* a temp file, used to save the union */ + /* definition until all symbol have been */ + /* defined */ +FILE *verbose_file; /* y.output */ + +int nitems; +int nrules; +int nsyms; +int ntokens; +int nvars; + +int start_symbol; +char **symbol_name; +short *symbol_value; +short *symbol_prec; +char *symbol_assoc; + +short *ritem; +short *rlhs; +short *rrhs; +short *rprec; +char *rassoc; +short **derives; +char *nullable; + +static const char *file_prefix = "y"; +static const char *temp_form = "yacc.XXXXXXX"; +static int explicit_file_name; + + +static __dead void onintr(int); +static void set_signals(void); +static __dead void usage(void); +static void getargs(int, char *[]); +static void create_file_names(void); +static void open_files(void); + +/* coverity[+kill] */ +__dead void +done(int k) +{ + if (action_file) { fclose(action_file); unlink(action_file_name); } + if (text_file) { fclose(text_file); unlink(text_file_name); } + if (union_file) { fclose(union_file); unlink(union_file_name); } + exit(k); +} + + +static void +onintr(int signo) +{ + done(1); +} + + +static void +set_signals() +{ +#ifdef SIGINT + if (signal(SIGINT, SIG_IGN) != SIG_IGN) + signal(SIGINT, onintr); +#endif +#ifdef SIGTERM + if (signal(SIGTERM, SIG_IGN) != SIG_IGN) + signal(SIGTERM, onintr); +#endif +#ifdef SIGHUP + if (signal(SIGHUP, SIG_IGN) != SIG_IGN) + signal(SIGHUP, onintr); +#endif +} + + +static void +usage(void) +{ + fprintf(stderr, "usage: %s [-dlrtv] [-b file_prefix] [-o outputfile] " + "[-p symbol_prefix] filename\n", myname); + exit(1); +} + + +static void +getargs(int argc, char *argv[]) +{ + int i; + char *s; + + if (argc > 0) myname = argv[0]; + for (i = 1; i < argc; ++i) + { + s = argv[i]; + if (*s != '-') break; + switch (*++s) + { + case '\0': + input_file = stdin; + if (i + 1 < argc) usage(); + return; + + case '-': + ++i; + goto no_more_options; + + case 'b': + if (*++s) + file_prefix = s; + else if (++i < argc) + file_prefix = argv[i]; + else + usage(); + continue; + + case 'd': + dflag = 1; + break; + + case 'l': + lflag = 1; + break; + + case 'o': + if (*++s) + output_file_name = s; + else if (++i < argc) + output_file_name = argv[i]; + else + usage(); + explicit_file_name = 1; + continue; + + case 'p': + if (*++s) + symbol_prefix = s; + else if (++i < argc) + symbol_prefix = argv[i]; + else + usage(); + continue; + + case 'r': + rflag = 1; + break; + + case 't': + tflag = 1; + break; + + case 'v': + vflag = 1; + break; + + default: + usage(); + } + + for (;;) + { + switch (*++s) + { + case '\0': + goto end_of_option; + + case 'd': + dflag = 1; + break; + + case 'l': + lflag = 1; + break; + + case 'r': + rflag = 1; + break; + + case 't': + tflag = 1; + break; + + case 'v': + vflag = 1; + break; + + default: + usage(); + } + } +end_of_option:; + } + +no_more_options:; + if (i + 1 != argc) usage(); + input_file_name = argv[i]; +} + + +char * +allocate(unsigned n) +{ + char *p; + + p = NULL; + if (n) + { + p = CALLOC(1, n); + if (!p) no_space(); + } + return (p); +} + + +static void +create_file_names(void) +{ + int i, len; + const char *tmpdir; + + tmpdir = getenv("TMPDIR"); + if (tmpdir == 0) tmpdir = "/tmp"; + + len = strlen(tmpdir); + i = len + 13; + if (len && tmpdir[len-1] != '/') + ++i; + + action_file_name = MALLOC(i); + if (action_file_name == 0) no_space(); + text_file_name = MALLOC(i); + if (text_file_name == 0) no_space(); + union_file_name = MALLOC(i); + if (union_file_name == 0) no_space(); + + strlcpy(action_file_name, tmpdir, i); + strlcpy(text_file_name, tmpdir, i); + strlcpy(union_file_name, tmpdir, i); + + if (len && tmpdir[len - 1] != '/') + { + action_file_name[len] = '/'; + text_file_name[len] = '/'; + union_file_name[len] = '/'; + ++len; + } + + strlcpy(action_file_name + len, temp_form, i - len); + strlcpy(text_file_name + len, temp_form, i - len); + strlcpy(union_file_name + len, temp_form, i - len); + + action_file_name[len + 5] = 'a'; + text_file_name[len + 5] = 't'; + union_file_name[len + 5] = 'u'; + + len = strlen(file_prefix); + + if (!output_file_name) + { + output_file_name = MALLOC(strlen(file_prefix) + strlen(OUTPUT_SUFFIX) + + 1); + if (output_file_name == 0) + no_space(); + sprintf(output_file_name, "%s%s", file_prefix, OUTPUT_SUFFIX); + } + + + if (rflag) + { + code_file_name = MALLOC(strlen(file_prefix) + strlen(CODE_SUFFIX) + + 1); + if (code_file_name == 0) + no_space(); + sprintf(code_file_name, "%s%s", file_prefix, CODE_SUFFIX); + } + else + code_file_name = output_file_name; + + if (dflag) + { + if (explicit_file_name) + { + char *suffix; + defines_file_name = strdup(output_file_name); + if (defines_file_name == 0) + no_space(); + /* does the output_file_name have a known suffix */ + suffix = strrchr(output_file_name, '.'); + if (suffix != 0 && + (!strcmp(suffix, ".c") || /* good, old-fashioned C */ + !strcmp(suffix, ".C") || /* C++, or C on Windows */ + !strcmp(suffix, ".cc") || /* C++ */ + !strcmp(suffix, ".cxx") || /* C++ */ + !strcmp(suffix, ".cpp"))) /* C++ (Windows) */ + { + strncpy(defines_file_name, output_file_name, + suffix - output_file_name + 1); + defines_file_name[suffix - output_file_name + 1] = 'h'; + defines_file_name[suffix - output_file_name + 2] = 0; + } else { + fprintf(stderr,"%s: suffix of output file name %s" + " not recognized, no -d file generated.\n", + myname, output_file_name); + dflag = 0; + free(defines_file_name); + defines_file_name = 0; + } + } + else + { + defines_file_name = MALLOC(strlen(file_prefix) + strlen(DEFINES_SUFFIX) + + 1); + if (defines_file_name == 0) + no_space(); + sprintf(defines_file_name, "%s%s", file_prefix, DEFINES_SUFFIX); + } + } + + if (vflag) + { + verbose_file_name = MALLOC(strlen(file_prefix) + strlen(VERBOSE_SUFFIX) + + 1); + if (verbose_file_name == 0) + no_space(); + sprintf(verbose_file_name, "%s%s", file_prefix, VERBOSE_SUFFIX); + + } +} + + +static void +open_files(void) +{ + int fd; + + create_file_names(); + + if (input_file == 0) + { + input_file = fopen(input_file_name, "r"); + if (input_file == 0) + open_error(input_file_name); + } + + if (((fd = mkstemp(action_file_name)) == -1) || + (action_file = fdopen(fd, "w")) == NULL) + open_error(action_file_name); + + if (((fd = mkstemp(text_file_name)) == -1) || + (text_file = fdopen(fd, "w")) == NULL) + open_error(text_file_name); + + if (vflag) + { + verbose_file = fopen(verbose_file_name, "w"); + if (verbose_file == 0) + open_error(verbose_file_name); + } + + if (dflag) + { + defines_file = fopen(defines_file_name, "w"); + if (defines_file == 0) + open_error(defines_file_name); + if (((fd = mkstemp(union_file_name)) == -1) || + (union_file = fdopen(fd, "w")) == NULL) + open_error(union_file_name); + } + + output_file = fopen(output_file_name, "w"); + if (output_file == 0) + open_error(output_file_name); + + if (rflag) + { + code_file = fopen(code_file_name, "w"); + if (code_file == 0) + open_error(code_file_name); + } + else + code_file = output_file; +} + + +int +main(int argc, char *argv[]) +{ + set_signals(); + getargs(argc, argv); + open_files(); + reader(); + lr0(); + lalr(); + make_parser(); + verbose(); + output(); + done(0); + /*NOTREACHED*/ + return 0; +} diff --git a/commands/byacc/mkpar.c b/commands/yacc/mkpar.c similarity index 52% rename from commands/byacc/mkpar.c rename to commands/yacc/mkpar.c index e1aef60fe..6f0eb3fbe 100644 --- a/commands/byacc/mkpar.c +++ b/commands/yacc/mkpar.c @@ -1,3 +1,45 @@ +/* $NetBSD: mkpar.c,v 1.12 2009/04/14 09:41:31 lukem Exp $ */ + +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Robert Paul Corbett. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#if defined(__RCSID) && !defined(lint) +#if 0 +static char sccsid[] = "@(#)mkpar.c 5.3 (Berkeley) 1/20/91"; +#else +__RCSID("$NetBSD: mkpar.c,v 1.12 2009/04/14 09:41:31 lukem Exp $"); +#endif +#endif /* not lint */ #include "defs.h" @@ -14,15 +56,25 @@ short final_state; static int SRcount; static int RRcount; -extern action *parse_actions(); -extern action *get_shifts(); -extern action *add_reductions(); -extern action *add_reduce(); +static action *parse_actions(int); +static action *get_shifts(int); +static action *add_reductions(int, action *); +static action *add_reduce(action *, int, int); + +static int sole_reduction(int); +static void free_action_row(action *); + +static void find_final_state(void); +static void unused_rules(void); +static void remove_conflicts(void); +static void total_conflicts(void); +static void defreds(void); -make_parser() +void +make_parser(void) { - register int i; + int i; parser = NEW2(nstates, action *); for (i = 0; i < nstates; i++) @@ -36,11 +88,10 @@ make_parser() } -action * -parse_actions(stateno) -register int stateno; +static action * +parse_actions(int stateno) { - register action *actions; + action *actions; actions = get_shifts(stateno); actions = add_reductions(stateno, actions); @@ -48,24 +99,23 @@ register int stateno; } -action * -get_shifts(stateno) -int stateno; +static action * +get_shifts(int stateno) { - register action *actions, *temp; - register shifts *sp; - register short *to_state; - register int i, k; - register int symbol; + action *actions, *temp; + shifts *sp; + short *state; + int i, k; + int symbol; actions = 0; sp = shift_table[stateno]; if (sp) { - to_state = sp->shift; + state = sp->shift; for (i = sp->nshifts - 1; i >= 0; i--) { - k = to_state[i]; + k = state[i]; symbol = accessing_symbol[k]; if (ISTOKEN(symbol)) { @@ -83,14 +133,12 @@ int stateno; return (actions); } -action * -add_reductions(stateno, actions) -int stateno; -register action *actions; +static action * +add_reductions(int stateno, action *actions) { - register int i, j, m, n; - register int ruleno, tokensetsize; - register unsigned *rowp; + int i, j, m, n; + int ruleno, tokensetsize; + unsigned *rowp; tokensetsize = WORDSIZE(ntokens); m = lookaheads[stateno]; @@ -109,12 +157,10 @@ register action *actions; } -action * -add_reduce(actions, ruleno, symbol) -register action *actions; -register int ruleno, symbol; +static action * +add_reduce(action *actions, int ruleno, int symbol) { - register action *temp, *prev, *next; + action *temp, *prev, *next; prev = 0; for (next = actions; next && next->symbol < symbol; next = next->next) @@ -150,27 +196,29 @@ register int ruleno, symbol; } -find_final_state() +static void +find_final_state(void) { - register int goal, i; - register short *to_state; - register shifts *p; + int goal, i; + short *state; + shifts *p; p = shift_table[0]; - to_state = p->shift; + state = p->shift; goal = ritem[1]; for (i = p->nshifts - 1; i >= 0; --i) { - final_state = to_state[i]; + final_state = state[i]; if (accessing_symbol[final_state] == goal) break; } } -unused_rules() +static void +unused_rules(void) { - register int i; - register action *p; + int i; + action *p; rules_used = (short *) MALLOC(nrules*sizeof(short)); if (rules_used == 0) no_space(); @@ -191,20 +239,23 @@ unused_rules() for (i = 3; i < nrules; ++i) if (!rules_used[i]) ++nunused; - if (nunused) + if (nunused) { if (nunused == 1) fprintf(stderr, "%s: 1 rule never reduced\n", myname); else fprintf(stderr, "%s: %d rules never reduced\n", myname, nunused); + } } -remove_conflicts() +static void +remove_conflicts(void) { - register int i; - register int symbol; - register action *p, *pref; + int i; + int symbol; + action *p, *pref; + pref = NULL; SRtotal = 0; RRtotal = 0; SRconflicts = NEW2(nstates, short); @@ -226,45 +277,49 @@ remove_conflicts() SRcount++; p->suppressed = 1; } - else if (pref->action_code == SHIFT) + else { - if (pref->prec > 0 && p->prec > 0) + assert(pref != NULL); + if (pref->action_code == SHIFT) { - if (pref->prec < p->prec) + if (pref->prec > 0 && p->prec > 0) { - pref->suppressed = 2; - pref = p; - } - else if (pref->prec > p->prec) - { - p->suppressed = 2; - } - else if (pref->assoc == LEFT) - { - pref->suppressed = 2; - pref = p; - } - else if (pref->assoc == RIGHT) - { - p->suppressed = 2; + if (pref->prec < p->prec) + { + pref->suppressed = 2; + pref = p; + } + else if (pref->prec > p->prec) + { + p->suppressed = 2; + } + else if (pref->assoc == LEFT) + { + pref->suppressed = 2; + pref = p; + } + else if (pref->assoc == RIGHT) + { + p->suppressed = 2; + } + else + { + pref->suppressed = 2; + p->suppressed = 2; + } } else { - pref->suppressed = 2; - p->suppressed = 2; + SRcount++; + p->suppressed = 1; } } else { - SRcount++; + RRcount++; p->suppressed = 1; } } - else - { - RRcount++; - p->suppressed = 1; - } } SRtotal += SRcount; RRtotal += RRcount; @@ -274,7 +329,8 @@ remove_conflicts() } -total_conflicts() +static void +total_conflicts(void) { fprintf(stderr, "%s: ", myname); if (SRtotal == 1) @@ -294,12 +350,11 @@ total_conflicts() } -int -sole_reduction(stateno) -int stateno; +static int +sole_reduction(int stateno) { - register int count, ruleno; - register action *p; + int count, ruleno; + action *p; count = 0; ruleno = 0; @@ -323,19 +378,20 @@ int stateno; } -defreds() +static void +defreds(void) { - register int i; + int i; defred = NEW2(nstates, short); for (i = 0; i < nstates; i++) defred[i] = sole_reduction(i); } - -free_action_row(p) -register action *p; + +static void +free_action_row(action *p) { - register action *q; + action *q; while (p) { @@ -345,13 +401,13 @@ register action *p; } } -free_parser() +void +free_parser(void) { - register int i; + int i; for (i = 0; i < nstates; i++) free_action_row(parser[i]); FREE(parser); } - diff --git a/commands/byacc/output.c b/commands/yacc/output.c similarity index 77% rename from commands/byacc/output.c rename to commands/yacc/output.c index 6e4bb79c5..bf9e9d200 100644 --- a/commands/byacc/output.c +++ b/commands/yacc/output.c @@ -1,3 +1,46 @@ +/* $NetBSD: output.c,v 1.15 2009/04/14 09:41:31 lukem Exp $ */ + +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Robert Paul Corbett. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#if defined(__RCSID) && !defined(lint) +#if 0 +static char sccsid[] = "@(#)output.c 5.7 (Berkeley) 5/24/93"; +#else +__RCSID("$NetBSD: output.c,v 1.15 2009/04/14 09:41:31 lukem Exp $"); +#endif +#endif /* not lint */ + #include "defs.h" static int nvectors; @@ -16,8 +59,36 @@ static short *check; static int lowzero; static int high; +static void output_prefix(void); +static void output_rule_data(void); +static void output_yydefred(void); +static void output_actions(void); +static void token_actions(void); +static void goto_actions(void); +static int default_goto(int); +static void save_column(int, int); +static void sort_actions(void); +static void pack_table(void); +static int matching_vector(int); +static int pack_vector(int); +static void output_base(void); +static void output_table(void); +static void output_check(void); +static int is_C_identifier(char *); +static void output_defines(void); +static void output_stored_text(void); +static void output_debug(void); +static void output_stype(void); +static void output_trailing_text(void); +static void output_semantic_actions(void); +static void free_itemsets(void); +static void free_shifts(void); +static void free_reductions(void); -output() +static const char line_format[] = "#line %d \"%s\"\n"; + +void +output(void) { free_itemsets(); free_shifts(); @@ -39,8 +110,8 @@ output() write_section(trailer); } - -output_prefix() +static void +output_prefix(void) { if (symbol_prefix == NULL) symbol_prefix = "yy"; @@ -67,12 +138,16 @@ output_prefix() ++outline; fprintf(code_file, "#define yyss %sss\n", symbol_prefix); ++outline; + fprintf(code_file, "#define yysslim %ssslim\n", symbol_prefix); + ++outline; fprintf(code_file, "#define yyssp %sssp\n", symbol_prefix); ++outline; fprintf(code_file, "#define yyvs %svs\n", symbol_prefix); ++outline; fprintf(code_file, "#define yyvsp %svsp\n", symbol_prefix); ++outline; + fprintf(code_file, "#define yystacksize %sstacksize\n", symbol_prefix); + ++outline; fprintf(code_file, "#define yylhs %slhs\n", symbol_prefix); ++outline; fprintf(code_file, "#define yylen %slen\n", symbol_prefix); @@ -99,14 +174,14 @@ output_prefix() fprintf(code_file, "#define YYPREFIX \"%s\"\n", symbol_prefix); } - -output_rule_data() +static void +output_rule_data(void) { - register int i; - register int j; + int i; + int j; - fprintf(output_file, "short %slhs[] = {%42d,", symbol_prefix, + fprintf(output_file, "const short %slhs[] = {%42d,", symbol_prefix, symbol_value[start_symbol]); j = 10; @@ -126,7 +201,7 @@ output_rule_data() if (!rflag) outline += 2; fprintf(output_file, "\n};\n"); - fprintf(output_file, "short %slen[] = {%42d,", symbol_prefix, 2); + fprintf(output_file, "const short %slen[] = {%42d,", symbol_prefix, 2); j = 10; for (i = 3; i < nrules; i++) @@ -146,12 +221,12 @@ output_rule_data() fprintf(output_file, "\n};\n"); } - -output_yydefred() +static void +output_yydefred(void) { - register int i, j; + int i, j; - fprintf(output_file, "short %sdefred[] = {%39d,", symbol_prefix, + fprintf(output_file, "const short %sdefred[] = {%39d,", symbol_prefix, (defred[0] ? defred[0] - 2 : 0)); j = 10; @@ -173,8 +248,8 @@ output_yydefred() fprintf(output_file, "\n};\n"); } - -output_actions() +static void +output_actions(void) { nvectors = 2*nstates + nvars; @@ -201,14 +276,14 @@ output_actions() output_check(); } - -token_actions() +static void +token_actions(void) { - register int i, j; - register int shiftcount, reducecount; - register int max, min; - register short *actionrow, *r, *s; - register action *p; + int i, j; + int shiftcount, reducecount; + int max, min; + short *actionrow, *r, *s; + action *p; actionrow = NEW2(2*ntokens, short); for (i = 0; i < nstates; ++i) @@ -286,14 +361,15 @@ token_actions() FREE(actionrow); } -goto_actions() +static void +goto_actions(void) { - register int i, j, k; + int i, j, k; state_count = NEW2(nstates, short); k = default_goto(start_symbol + 1); - fprintf(output_file, "short %sdgoto[] = {%40d,", symbol_prefix, k); + fprintf(output_file, "const short %sdgoto[] = {%40d,", symbol_prefix, k); save_column(start_symbol + 1, k); j = 10; @@ -318,15 +394,14 @@ goto_actions() FREE(state_count); } -int -default_goto(symbol) -int symbol; +static int +default_goto(int symbol) { - register int i; - register int m; - register int n; - register int default_state; - register int max; + int i; + int m; + int n; + int default_state; + int max; m = goto_map[symbol]; n = goto_map[symbol + 1]; @@ -354,19 +429,17 @@ int symbol; } - -save_column(symbol, default_state) -int symbol; -int default_state; +static void +save_column(int symbol, int default_state) { - register int i; - register int m; - register int n; - register short *sp; - register short *sp1; - register short *sp2; - register int count; - register int symno; + int i; + int m; + int n; + short *sp; + short *sp1; + short *sp2; + int count; + int symno; m = goto_map[symbol]; n = goto_map[symbol + 1]; @@ -397,13 +470,14 @@ int default_state; width[symno] = sp1[-1] - sp[0] + 1; } -sort_actions() +static void +sort_actions(void) { - register int i; - register int j; - register int k; - register int t; - register int w; + int i; + int j; + int k; + int t; + int w; order = NEW2(nvectors, short); nentries = 0; @@ -432,16 +506,17 @@ sort_actions() } -pack_table() +static void +pack_table(void) { - register int i; - register int place; - register int state; + int i; + int place; + int state; base = NEW2(nvectors, short); pos = NEW2(nentries, short); - maxtable = BITS_PER_WORD == 16 ? 400 : 1000; + maxtable = 1000; table = NEW2(maxtable, short); check = NEW2(maxtable, short); @@ -494,17 +569,16 @@ pack_table() /* faster. Also, it depends on the vectors being in a specific */ /* order. */ -int -matching_vector(vector) -int vector; +static int +matching_vector(int vector) { - register int i; - register int j; - register int k; - register int t; - register int w; - register int match; - register int prev; + int i; + int j; + int k; + int t; + int w; + int match; + int prev; i = order[vector]; if (i >= 2*nstates) @@ -535,16 +609,15 @@ int vector; -int -pack_vector(vector) -int vector; +static int +pack_vector(int vector) { - register int i, j, k, l; - register int t; - register int loc; - register int ok; - register short *from; - register short *to; + int i, j, k, l; + int t; + int loc; + int ok; + short *from; + short *to; int newmax; i = order[vector]; @@ -612,12 +685,13 @@ int vector; } - -output_base() +static void +output_base(void) { - register int i, j; + int i, j; - fprintf(output_file, "short %ssindex[] = {%39d,", symbol_prefix, base[0]); + fprintf(output_file, "const short %ssindex[] = {%39d,", symbol_prefix, + base[0]); j = 10; for (i = 1; i < nstates; i++) @@ -635,7 +709,7 @@ output_base() } if (!rflag) outline += 2; - fprintf(output_file, "\n};\nshort %srindex[] = {%39d,", symbol_prefix, + fprintf(output_file, "\n};\nconst short %srindex[] = {%39d,", symbol_prefix, base[nstates]); j = 10; @@ -654,7 +728,7 @@ output_base() } if (!rflag) outline += 2; - fprintf(output_file, "\n};\nshort %sgindex[] = {%39d,", symbol_prefix, + fprintf(output_file, "\n};\nconst short %sgindex[] = {%39d,", symbol_prefix, base[2*nstates]); j = 10; @@ -678,15 +752,15 @@ output_base() } - -output_table() +static void +output_table(void) { - register int i; - register int j; + int i; + int j; ++outline; fprintf(code_file, "#define YYTABLESIZE %d\n", high); - fprintf(output_file, "short %stable[] = {%40d,", symbol_prefix, + fprintf(output_file, "const short %stable[] = {%40d,", symbol_prefix, table[0]); j = 10; @@ -710,13 +784,13 @@ output_table() } - -output_check() +static void +output_check(void) { - register int i; - register int j; + int i; + int j; - fprintf(output_file, "short %scheck[] = {%40d,", symbol_prefix, + fprintf(output_file, "const short %scheck[] = {%40d,", symbol_prefix, check[0]); j = 10; @@ -740,12 +814,11 @@ output_check() } -int -is_C_identifier(name) -char *name; +static int +is_C_identifier(char *name) { - register char *s; - register int c; + char *s; + unsigned char c; s = name; c = *s; @@ -764,7 +837,7 @@ char *name; if (!isalpha(c) && c != '_' && c != '$') return (0); - while (c = *++s) + while ((c = *++s) != '\0') { if (!isalnum(c) && c != '_' && c != '$') return (0); @@ -773,10 +846,11 @@ char *name; } -output_defines() +static void +output_defines(void) { - register int c, i; - register char *s; + int c, i; + char *s; for (i = 2; i < ntokens; ++i) { @@ -801,7 +875,7 @@ output_defines() putc(c, code_file); if (dflag) putc(c, defines_file); } - while (c = *++s); + while ((c = *++s) != '\0'); } ++outline; fprintf(code_file, " %d\n", symbol_value[i]); @@ -825,10 +899,11 @@ output_defines() } -output_stored_text() +static void +output_stored_text(void) { - register int c; - register FILE *in, *out; + int c; + FILE *in, *out; fclose(text_file); text_file = fopen(text_file_name, "r"); @@ -852,10 +927,11 @@ output_stored_text() } -output_debug() +static void +output_debug(void) { - register int i, j, k, max; - char **symnam, *s; + int i, j, k, max; + const char **symnam, *s; ++outline; fprintf(code_file, "#define YYFINAL %d\n", final_state); @@ -873,7 +949,7 @@ output_debug() ++outline; fprintf(code_file, "#define YYMAXTOKEN %d\n", max); - symnam = (char **) MALLOC((max+1)*sizeof(char *)); + symnam = (const char **) MALLOC((max+1)*sizeof(char *)); if (symnam == 0) no_space(); /* Note that it is not necessary to initialize the element */ @@ -885,11 +961,12 @@ output_debug() symnam[0] = "end-of-file"; if (!rflag) ++outline; - fprintf(output_file, "#if YYDEBUG\nchar *%sname[] = {", symbol_prefix); + fprintf(output_file, "#if YYDEBUG\nconst char * const %sname[] = {", + symbol_prefix); j = 80; for (i = 0; i <= max; ++i) { - if (s = symnam[i]) + if ((s = symnam[i]) != NULL) { if (s[0] == '"') { @@ -1011,7 +1088,7 @@ output_debug() FREE(symnam); if (!rflag) ++outline; - fprintf(output_file, "char *%srule[] = {\n", symbol_prefix); + fprintf(output_file, "const char * const %srule[] = {\n", symbol_prefix); for (i = 2; i < nrules; ++i) { fprintf(output_file, "\"%s :", symbol_name[rlhs[i]]); @@ -1066,7 +1143,8 @@ output_debug() } -output_stype() +static void +output_stype(void) { if (!unionized && ntags == 0) { @@ -1076,10 +1154,11 @@ output_stype() } -output_trailing_text() +static void +output_trailing_text(void) { - register int c, last; - register FILE *in, *out; + int c, last; + FILE *in, *out; if (line == 0) return; @@ -1133,10 +1212,11 @@ output_trailing_text() } -output_semantic_actions() +static void +output_semantic_actions(void) { - register int c, last; - register FILE *out; + int c, last; + FILE *out; fclose(action_file); action_file = fopen(action_file_name, "r"); @@ -1170,9 +1250,10 @@ output_semantic_actions() } -free_itemsets() +static void +free_itemsets(void) { - register core *cp, *next; + core *cp, *next; FREE(state_table); for (cp = first_state; cp; cp = next) @@ -1183,9 +1264,10 @@ free_itemsets() } -free_shifts() +static void +free_shifts(void) { - register shifts *sp, *next; + shifts *sp, *next; FREE(shift_table); for (sp = first_shift; sp; sp = next) @@ -1196,10 +1278,10 @@ free_shifts() } - -free_reductions() +static void +free_reductions(void) { - register reductions *rp, *next; + reductions *rp, *next; FREE(reduction_table); for (rp = first_reduction; rp; rp = next) diff --git a/commands/byacc/reader.c b/commands/yacc/reader.c similarity index 80% rename from commands/byacc/reader.c rename to commands/yacc/reader.c index 059a04371..b1f5e32ec 100644 --- a/commands/byacc/reader.c +++ b/commands/yacc/reader.c @@ -1,41 +1,124 @@ +/* $NetBSD: reader.c,v 1.18 2009/04/14 09:41:31 lukem Exp $ */ + +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Robert Paul Corbett. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#if defined(__RCSID) && !defined(lint) +#if 0 +static char sccsid[] = "@(#)reader.c 5.7 (Berkeley) 1/20/91"; +#else +__RCSID("$NetBSD: reader.c,v 1.18 2009/04/14 09:41:31 lukem Exp $"); +#endif +#endif /* not lint */ + #include "defs.h" /* The line size must be a positive integer. One hundred was chosen */ /* because few lines in Yacc input grammars exceed 100 characters. */ /* Note that if a line exceeds LINESIZE characters, the line buffer */ -/* will be expanded to accomodate it. */ +/* will be expanded to accommodate it. */ #define LINESIZE 100 -char *cache; -int cinc, cache_size; - -int ntags, tagmax; -char **tag_table; - -char saw_eof, unionized; +int ntags; +char unionized; char *cptr, *line; -int linesize; -bucket *goal; -int prec; -int gensym; -char last_was_action; +static char *cache; +static int cinc, cache_size; -int maxitems; -bucket **pitem; +static int tagmax; +static char **tag_table; -int maxrules; -bucket **plhs; +static char saw_eof; +static int linesize; -int name_pool_size; -char *name_pool; +static bucket *goal; +static int gensym; +static char last_was_action; -char line_format[] = "#line %d \"%s\"\n"; +static int maxitems; +static bucket **pitem; + +static int maxrules; +static bucket **plhs; + +static int name_pool_size; +static char *name_pool; + +static void cachec(int); +static void get_line(void); +static char * dup_line(void); +static void skip_comment(void); +static int nextc(void); +static int keyword(void); +static void copy_ident(void); +static void copy_text(void); +static void copy_union(void); +static int hexval(int); +static bucket * get_literal(void); +static int is_reserved(char *); +static bucket * get_name(void); +static int get_number(void); +static char * get_tag(void); +static void declare_tokens(int); +static void declare_types(void); +static void declare_start(void); +static void handle_expect(void); +static void read_declarations(void); +static void initialize_grammar(void); +static void expand_items(void); +static void expand_rules(void); +static void advance_to_start(void); +static void start_rule(bucket *, int); +static void end_rule(void); +static void insert_empty_rule(void); +static void add_symbol(void); +static void copy_action(void); +static int mark_symbol(void); +static void read_grammar(void); +static void free_tags(void); +static void pack_names(void); +static void check_symbols(void); +static void pack_symbols(void); +static void pack_grammar(void); +static void print_grammar(void); -cachec(c) -int c; +static const char line_format[] = "#line %d \"%s\"\n"; + +static void +cachec(int c) { assert(cinc >= 0); if (cinc >= cache_size) @@ -48,12 +131,12 @@ int c; ++cinc; } - -get_line() +static void +get_line(void) { - register FILE *f = input_file; - register int c; - register int i; + FILE *f = input_file; + int c; + int i; if (saw_eof || (c = getc(f)) == EOF) { @@ -95,10 +178,10 @@ get_line() } -char * -dup_line() +static char * +dup_line(void) { - register char *p, *s, *t; + char *p, *s, *t; if (line == 0) return (0); s = line; @@ -113,9 +196,10 @@ dup_line() } -skip_comment() +static void +skip_comment(void) { - register char *s; + char *s; int st_lineno = lineno; char *st_line = dup_line(); @@ -143,10 +227,10 @@ skip_comment() } -int -nextc() +static int +nextc(void) { - register char *s; + char *s; if (line == 0) { @@ -205,10 +289,10 @@ nextc() } -int -keyword() +static int +keyword(void) { - register int c; + unsigned char c; char *t_cptr = cptr; c = *++cptr; @@ -246,6 +330,8 @@ keyword() return (UNION); if (strcmp(cache, "ident") == 0) return (IDENT); + if (strcmp(cache, "expect") == 0) + return (EXPECT); } else { @@ -265,13 +351,15 @@ keyword() } syntax_error(lineno, line, t_cptr); /*NOTREACHED*/ + exit(1); } -copy_ident() +static void +copy_ident(void) { - register int c; - register FILE *f = output_file; + int c; + FILE *f = output_file; c = nextc(); if (c == EOF) unexpected_EOF(); @@ -297,11 +385,12 @@ copy_ident() } -copy_text() +static void +copy_text(void) { - register int c; + int c; int quote; - register FILE *f = text_file; + FILE *f = text_file; int need_newline = 0; int t_lineno = lineno; char *t_line = dup_line(); @@ -428,9 +517,10 @@ loop: } -copy_union() +static void +copy_union(void) { - register int c; + int c; int quote; int depth; int u_lineno = lineno; @@ -568,9 +658,8 @@ loop: } -int -hexval(c) -int c; +static int +hexval(int c) { if (c >= '0' && c <= '9') return (c - '0'); @@ -582,14 +671,14 @@ int c; } -bucket * -get_literal() +static bucket * +get_literal(void) { - register int c, quote; - register int i; - register int n; - register char *s; - register bucket *bp; + int c, quote; + int i; + int n; + char *s; + bucket *bp; int s_lineno = lineno; char *s_line = dup_line(); char *s_cptr = s_line + (cptr - line); @@ -721,9 +810,8 @@ get_literal() } -int -is_reserved(name) -char *name; +static int +is_reserved(char *name) { char *s; @@ -732,10 +820,10 @@ char *name; strcmp(name, "$end") == 0) return (1); - if (name[0] == '$' && name[1] == '$' && isdigit(name[2])) + if (name[0] == '$' && name[1] == '$' && isdigit((unsigned char)name[2])) { s = name + 3; - while (isdigit(*s)) ++s; + while (isdigit((unsigned char)*s)) ++s; if (*s == NUL) return (1); } @@ -743,10 +831,10 @@ char *name; } -bucket * -get_name() +static bucket * +get_name(void) { - register int c; + int c; cinc = 0; for (c = *cptr; IS_IDENT(c); c = *++cptr) @@ -759,11 +847,11 @@ get_name() } -int -get_number() +static int +get_number(void) { - register int c; - register int n; + int c; + int n; n = 0; for (c = *cptr; isdigit(c); c = *++cptr) @@ -773,12 +861,12 @@ get_number() } -char * -get_tag() +static char * +get_tag(void) { - register int c; - register int i; - register char *s; + int c; + int i; + char *s; int t_lineno = lineno; char *t_line = dup_line(); char *t_cptr = t_line + (cptr - line); @@ -797,6 +885,7 @@ get_tag() if (c == EOF) unexpected_EOF(); if (c != '>') illegal_tag(t_lineno, t_line, t_cptr); + FREE(t_line); ++cptr; for (i = 0; i < ntags; ++i) @@ -819,18 +908,18 @@ get_tag() strcpy(s, cache); tag_table[ntags] = s; ++ntags; - FREE(t_line); return (s); } -declare_tokens(assoc) -int assoc; +static void +declare_tokens(int assoc) { - register int c; - register bucket *bp; + int c; + bucket *bp; int value; char *tag = 0; + static int prec; if (assoc != TOKEN) ++prec; @@ -886,10 +975,11 @@ int assoc; } -declare_types() +static void +declare_types(void) { - register int c; - register bucket *bp; + int c; + bucket *bp; char *tag; c = nextc(); @@ -914,10 +1004,11 @@ declare_types() } -declare_start() +static void +declare_start(void) { - register int c; - register bucket *bp; + int c; + bucket *bp; c = nextc(); if (c == EOF) unexpected_EOF(); @@ -932,9 +1023,28 @@ declare_start() } -read_declarations() +static void +handle_expect(void) { - register int c, k; + int c; + int num; + + c = nextc(); + if (c == EOF) unexpected_EOF(); + if (!isdigit(c)) + syntax_error(lineno, line, cptr); + num = get_number(); + if (num == 1) + fprintf (stderr, "%s: Expect 1 shift/reduce conflict.\n", myname); + else + fprintf (stderr, "%s: Expect %d shift/reduce conflicts.\n", myname, num); +} + + +static void +read_declarations(void) +{ + int c, k; cache_size = 256; cache = MALLOC(cache_size); @@ -976,12 +1086,17 @@ read_declarations() case START: declare_start(); break; + + case EXPECT: + handle_expect(); + break; } } } -initialize_grammar() +static void +initialize_grammar(void) { nitems = 4; maxitems = 300; @@ -1012,7 +1127,8 @@ initialize_grammar() } -expand_items() +static void +expand_items(void) { maxitems += 300; pitem = (bucket **) REALLOC(pitem, maxitems*sizeof(bucket *)); @@ -1020,7 +1136,8 @@ expand_items() } -expand_rules() +static void +expand_rules(void) { maxrules += 100; plhs = (bucket **) REALLOC(plhs, maxrules*sizeof(bucket *)); @@ -1032,10 +1149,11 @@ expand_rules() } -advance_to_start() +static void +advance_to_start(void) { - register int c; - register bucket *bp; + int c; + bucket *bp; char *s_cptr; int s_lineno; @@ -1082,9 +1200,8 @@ advance_to_start() } -start_rule(bp, s_lineno) -register bucket *bp; -int s_lineno; +static void +start_rule(bucket *bp, int s_lineno) { if (bp->class == TERM) terminal_lhs(s_lineno); @@ -1097,9 +1214,10 @@ int s_lineno; } -end_rule() +static void +end_rule(void) { - register int i; + int i; if (!last_was_action && plhs[nrules]->tag) { @@ -1116,12 +1234,13 @@ end_rule() } -insert_empty_rule() +static void +insert_empty_rule(void) { - register bucket *bp, **bpp; + bucket *bp, **bpp; assert(cache); - sprintf(cache, "$$%d", ++gensym); + snprintf(cache, cache_size, "$$%d", ++gensym); bp = make_bucket(cache); last_symbol->next = bp; last_symbol = bp; @@ -1132,7 +1251,7 @@ insert_empty_rule() expand_items(); bpp = pitem + nitems - 1; *bpp-- = bp; - while (bpp[0] = bpp[-1]) --bpp; + while ((bpp[0] = bpp[-1])) --bpp; if (++nrules >= maxrules) expand_rules(); @@ -1145,10 +1264,11 @@ insert_empty_rule() } -add_symbol() +static void +add_symbol(void) { - register int c; - register bucket *bp; + int c; + bucket *bp; int s_lineno = lineno; c = *cptr; @@ -1176,14 +1296,15 @@ add_symbol() } -copy_action() +static void +copy_action(void) { - register int c; - register int i, n; + int c; + int i, n; int depth; int quote; char *tag; - register FILE *f = action_file; + FILE *f = action_file; int a_lineno = lineno; char *a_line = dup_line(); char *a_cptr = a_line + (cptr - line); @@ -1229,7 +1350,7 @@ loop: FREE(d_line); goto loop; } - else if (c == '-' && isdigit(cptr[1])) + else if (c == '-' && isdigit((unsigned char)cptr[1])) { ++cptr; i = -get_number() - n; @@ -1253,7 +1374,7 @@ loop: cptr += 2; goto loop; } - else if (isdigit(cptr[1])) + else if (isdigit((unsigned char)cptr[1])) { ++cptr; i = get_number(); @@ -1305,6 +1426,7 @@ loop: case ';': if (depth > 0) goto loop; fprintf(f, "\nbreak;\n"); + FREE(a_line); return; case '{': @@ -1314,6 +1436,7 @@ loop: case '}': if (--depth > 0) goto loop; fprintf(f, "\nbreak;\n"); + FREE(a_line); return; case '\'': @@ -1399,11 +1522,13 @@ loop: } -int -mark_symbol() +static int +mark_symbol(void) { - register int c; - register bucket *bp; + int c; + bucket *bp; + + bp = NULL; c = cptr[1]; if (c == '%' || c == '\\') @@ -1443,9 +1568,10 @@ mark_symbol() } -read_grammar() +static void +read_grammar(void) { - register int c; + int c; initialize_grammar(); advance_to_start(); @@ -1476,9 +1602,10 @@ read_grammar() } -free_tags() +static void +free_tags(void) { - register int i; + int i; if (tag_table == 0) return; @@ -1491,10 +1618,11 @@ free_tags() } -pack_names() +static void +pack_names(void) { - register bucket *bp; - register char *p, *s, *t; + bucket *bp; + char *p, *s, *t; name_pool_size = 13; /* 13 == sizeof("$end") + sizeof("$accept") */ for (bp = first_symbol; bp; bp = bp->next) @@ -1502,23 +1630,24 @@ pack_names() name_pool = MALLOC(name_pool_size); if (name_pool == 0) no_space(); - strcpy(name_pool, "$accept"); - strcpy(name_pool+8, "$end"); + strlcpy(name_pool, "$accept", name_pool_size); + strlcpy(name_pool+8, "$end", name_pool_size - 8); t = name_pool + 13; for (bp = first_symbol; bp; bp = bp->next) { p = t; s = bp->name; - while (*t++ = *s++) continue; + while ((*t++ = *s++) != '\0') continue; FREE(bp->name); bp->name = p; } } -check_symbols() +static void +check_symbols(void) { - register bucket *bp; + bucket *bp; if (goal->class == UNKNOWN) undefined_goal(goal->name); @@ -1534,11 +1663,12 @@ check_symbols() } -pack_symbols() +static void +pack_symbols(void) { - register bucket *bp; - register bucket **v; - register int i, j, k, n; + bucket *bp; + bucket **v; + int i, j, k, n; nsyms = 2; ntokens = 1; @@ -1658,9 +1788,10 @@ pack_symbols() } -pack_grammar() +static void +pack_grammar(void) { - register int i, j; + int i, j; int assoc, prec; ritem = (short *) MALLOC(nitems*sizeof(short)); @@ -1717,12 +1848,15 @@ pack_grammar() } -print_grammar() +static void +print_grammar(void) { - register int i, j, k; + int i, j, k; int spacing; - register FILE *f = verbose_file; + FILE *f = verbose_file; + spacing = 0; + if (!vflag) return; k = 1; @@ -1753,7 +1887,8 @@ print_grammar() } -reader() +void +reader(void) { write_section(banner); create_symbol_table(); diff --git a/commands/byacc/skeleton.c b/commands/yacc/skeleton.c similarity index 59% rename from commands/byacc/skeleton.c rename to commands/yacc/skeleton.c index d2b6c9f09..79ee41be6 100644 --- a/commands/byacc/skeleton.c +++ b/commands/yacc/skeleton.c @@ -1,3 +1,46 @@ +/* $NetBSD: skeleton.c,v 1.29 2008/07/18 14:25:37 drochner Exp $ */ + +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Robert Paul Corbett. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#if defined(__RCSID) && !defined(lint) +#if 0 +static char sccsid[] = "@(#)skeleton.c 5.8 (Berkeley) 4/29/95"; +#else +__RCSID("$NetBSD: skeleton.c,v 1.29 2008/07/18 14:25:37 drochner Exp $"); +#endif /* 0 */ +#endif /* not lint */ + #include "defs.h" /* The definition of yysccsid in the banner should be replaced with */ @@ -12,41 +55,50 @@ /* the body either are not useful outside of semantic actions or */ /* are conditional. */ -char *banner[] = +const char * const banner[] = { + "#include ", "#ifndef lint", + "#if 0", "static char yysccsid[] = \"@(#)yaccpar 1.9 (Berkeley) 02/21/93\";", - "#endif", + "#else", + "#if defined(__NetBSD__) && defined(__IDSTRING)", + "__IDSTRING(yyrcsid, \"$NetBSD: skeleton.c,v 1.29 2008/07/18 14:25:37 drochner Exp $\");", + "#endif /* __NetBSD__ && __IDSTRING */", + "#endif /* 0 */", + "#endif /* lint */", "#define YYBYACC 1", "#define YYMAJOR 1", "#define YYMINOR 9", - "#define yyclearin (yychar=(-1))", + "#define YYLEX yylex()", + "#define YYEMPTY -1", + "#define yyclearin (yychar=(YYEMPTY))", "#define yyerrok (yyerrflag=0)", "#define YYRECOVERING (yyerrflag!=0)", 0 }; -char *tables[] = +const char * const tables[] = { - "extern short yylhs[];", - "extern short yylen[];", - "extern short yydefred[];", - "extern short yydgoto[];", - "extern short yysindex[];", - "extern short yyrindex[];", - "extern short yygindex[];", - "extern short yytable[];", - "extern short yycheck[];", + "extern const short yylhs[];", + "extern const short yylen[];", + "extern const short yydefred[];", + "extern const short yydgoto[];", + "extern const short yysindex[];", + "extern const short yyrindex[];", + "extern const short yygindex[];", + "extern const short yytable[];", + "extern const short yycheck[];", "#if YYDEBUG", - "extern char *yyname[];", - "extern char *yyrule[];", + "extern const char * const yyname[];", + "extern const char * const yyrule[];", "#endif", 0 }; -char *header[] = +const char * const header[] = { "#ifdef YYSTACKSIZE", "#undef YYMAXDEPTH", @@ -55,10 +107,11 @@ char *header[] = "#ifdef YYMAXDEPTH", "#define YYSTACKSIZE YYMAXDEPTH", "#else", - "#define YYSTACKSIZE 500", - "#define YYMAXDEPTH 500", + "#define YYSTACKSIZE 10000", + "#define YYMAXDEPTH 10000", "#endif", "#endif", + "#define YYINITSTACKSIZE 200", "int yydebug;", "int yynerrs;", "int yyerrflag;", @@ -66,29 +119,59 @@ char *header[] = "short *yyssp;", "YYSTYPE *yyvsp;", "YYSTYPE yyval;", + "static YYSTYPE yyvalzero;", /* no "const", must compile as C++ */ "YYSTYPE yylval;", - "short yyss[YYSTACKSIZE];", - "YYSTYPE yyvs[YYSTACKSIZE];", - "#define yystacksize YYSTACKSIZE", + "short *yyss;", + "short *yysslim;", + "YYSTYPE *yyvs;", + "int yystacksize;", + "int yyparse(void);", 0 }; -char *body[] = +const char * const body[] = { + "/* allocate initial stack or double stack size, up to YYMAXDEPTH */", + "static int yygrowstack(void);", + "static int yygrowstack(void)", + "{", + " int newsize, i;", + " short *newss;", + " YYSTYPE *newvs;", + "", + " if ((newsize = yystacksize) == 0)", + " newsize = YYINITSTACKSIZE;", + " else if (newsize >= YYMAXDEPTH)", + " return -1;", + " else if ((newsize *= 2) > YYMAXDEPTH)", + " newsize = YYMAXDEPTH;", + " i = yyssp - yyss;", + " if ((newss = (short *)realloc(yyss, newsize * sizeof *newss)) == NULL)", + " return -1;", + " yyss = newss;", + " yyssp = newss + i;", + " if ((newvs = (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs)) == NULL)", + " return -1;", + " yyvs = newvs;", + " yyvsp = newvs + i;", + " yystacksize = newsize;", + " yysslim = yyss + newsize - 1;", + " return 0;", + "}", + "", "#define YYABORT goto yyabort", "#define YYREJECT goto yyabort", "#define YYACCEPT goto yyaccept", "#define YYERROR goto yyerrlab", "int", - "yyparse()", + "yyparse(void)", "{", - " register int yym, yyn, yystate;", + " int yym, yyn, yystate;", "#if YYDEBUG", - " register char *yys;", - " extern char *getenv();", + " const char *yys;", "", - " if (yys = getenv(\"YYDEBUG\"))", + " if ((yys = getenv(\"YYDEBUG\")) != NULL)", " {", " yyn = *yys;", " if (yyn >= '0' && yyn <= '9')", @@ -100,12 +183,13 @@ char *body[] = " yyerrflag = 0;", " yychar = (-1);", "", + " if (yyss == NULL && yygrowstack()) goto yyoverflow;", " yyssp = yyss;", " yyvsp = yyvs;", " *yyssp = yystate = 0;", "", "yyloop:", - " if (yyn = yydefred[yystate]) goto yyreduce;", + " if ((yyn = yydefred[yystate]) != 0) goto yyreduce;", " if (yychar < 0)", " {", " if ((yychar = yylex()) < 0) yychar = 0;", @@ -128,7 +212,7 @@ char *body[] = " printf(\"%sdebug: state %d, shifting to state %d\\n\",", " YYPREFIX, yystate, yytable[yyn]);", "#endif", - " if (yyssp >= yyss + yystacksize - 1)", + " if (yyssp >= yysslim && yygrowstack())", " {", " goto yyoverflow;", " }", @@ -145,14 +229,10 @@ char *body[] = " goto yyreduce;", " }", " if (yyerrflag) goto yyinrecovery;", - "#ifdef lint", " goto yynewerror;", - "#endif", "yynewerror:", " yyerror(\"syntax error\");", - "#ifdef lint", " goto yyerrlab;", - "#endif", "yyerrlab:", " ++yynerrs;", "yyinrecovery:", @@ -169,7 +249,7 @@ char *body[] = " printf(\"%sdebug: state %d, error recovery shifting\\", " to state %d\\n\", YYPREFIX, *yyssp, yytable[yyn]);", "#endif", - " if (yyssp >= yyss + yystacksize - 1)", + " if (yyssp >= yysslim && yygrowstack())", " {", " goto yyoverflow;", " }", @@ -215,14 +295,17 @@ char *body[] = " YYPREFIX, yystate, yyn, yyrule[yyn]);", "#endif", " yym = yylen[yyn];", - " yyval = yyvsp[1-yym];", + " if (yym)", + " yyval = yyvsp[1-yym];", + " else", + " yyval = yyvalzero;", " switch (yyn)", " {", 0 }; -char *trailer[] = +const char * const trailer[] = { " }", " yyssp -= yym;", @@ -266,7 +349,7 @@ char *trailer[] = " printf(\"%sdebug: after reduction, shifting from state %d \\", "to state %d\\n\", YYPREFIX, *yyssp, yystate);", "#endif", - " if (yyssp >= yyss + yystacksize - 1)", + " if (yyssp >= yysslim && yygrowstack())", " {", " goto yyoverflow;", " }", @@ -284,19 +367,19 @@ char *trailer[] = }; -write_section(section) -char *section[]; +void +write_section(const char * const section[]) { - register int c; - register int i; - register char *s; - register FILE *f; + int c; + int i; + const char *s; + FILE *f; f = code_file; - for (i = 0; s = section[i]; ++i) + for (i = 0; (s = section[i]); ++i) { ++outline; - while (c = *s) + while ((c = *s) != '\0') { putc(c, f); ++s; diff --git a/commands/yacc/symtab.c b/commands/yacc/symtab.c new file mode 100644 index 000000000..c7f0e801b --- /dev/null +++ b/commands/yacc/symtab.c @@ -0,0 +1,161 @@ +/* $NetBSD: symtab.c,v 1.12 2009/04/14 09:41:31 lukem Exp $ */ + +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Robert Paul Corbett. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#if defined(__RCSID) && !defined(lint) +#if 0 +static char sccsid[] = "@(#)symtab.c 5.3 (Berkeley) 6/1/90"; +#else +__RCSID("$NetBSD: symtab.c,v 1.12 2009/04/14 09:41:31 lukem Exp $"); +#endif +#endif /* not lint */ + +#include "defs.h" + +/* TABLE_SIZE is the number of entries in the symbol table. */ +/* TABLE_SIZE must be a power of two. */ + +#define TABLE_SIZE 1024 + + +bucket *first_symbol; +bucket *last_symbol; + +static bucket **symbol_table; + +static int hash(const char *); + + +static int +hash(const char *name) +{ + const char *s; + int c, k; + + assert(name && *name); + s = name; + k = *s; + while ((c = *++s) != '\0') + k = (31*k + c) & (TABLE_SIZE - 1); + + return (k); +} + + +bucket * +make_bucket(const char *name) +{ + bucket *bp; + + assert(name); + bp = (bucket *) MALLOC(sizeof(bucket)); + if (bp == 0) no_space(); + bp->link = 0; + bp->next = 0; + bp->name = strdup(name); + if (bp->name == 0) no_space(); + bp->tag = 0; + bp->value = UNDEFINED; + bp->index = 0; + bp->prec = 0; + bp-> class = UNKNOWN; + bp->assoc = TOKEN; + + return (bp); +} + + +bucket * +lookup(char *name) +{ + bucket *bp, **bpp; + + bpp = symbol_table + hash(name); + bp = *bpp; + + while (bp) + { + if (strcmp(name, bp->name) == 0) return (bp); + bpp = &bp->link; + bp = *bpp; + } + + *bpp = bp = make_bucket(name); + last_symbol->next = bp; + last_symbol = bp; + + return (bp); +} + + +void +create_symbol_table(void) +{ + int i; + bucket *bp; + + symbol_table = (bucket **) MALLOC(TABLE_SIZE*sizeof(bucket *)); + if (symbol_table == 0) no_space(); + for (i = 0; i < TABLE_SIZE; i++) + symbol_table[i] = 0; + + bp = make_bucket("error"); + bp->index = 1; + bp->class = TERM; + + first_symbol = bp; + last_symbol = bp; + symbol_table[hash("error")] = bp; +} + + +void +free_symbol_table(void) +{ + FREE(symbol_table); + symbol_table = 0; +} + + +void +free_symbols(void) +{ + bucket *p, *q; + + for (p = first_symbol; p; p = q) + { + q = p->next; + FREE(p); + } +} diff --git a/commands/yacc/test/error.output b/commands/yacc/test/error.output new file mode 100644 index 000000000..0c4db6225 --- /dev/null +++ b/commands/yacc/test/error.output @@ -0,0 +1,27 @@ + 0 $accept : S $end + + 1 S : error + +state 0 + $accept : . S $end (0) + + error shift 1 + . error + + S goto 2 + + +state 1 + S : error . (1) + + . reduce 1 + + +state 2 + $accept : S . $end (0) + + $end accept + + +2 terminals, 2 nonterminals +2 grammar rules, 3 states diff --git a/commands/yacc/test/error.tab.c b/commands/yacc/test/error.tab.c new file mode 100644 index 000000000..f8a86636c --- /dev/null +++ b/commands/yacc/test/error.tab.c @@ -0,0 +1,276 @@ +#ifndef lint +/*static char yysccsid[] = "from: @(#)yaccpar 1.9 (Berkeley) 02/21/93";*/ +static char rcsid[] = "$NetBSD: error.tab.c,v 1.4 1997/01/09 20:23:30 tls Exp $"; +#endif +#define YYBYACC 1 +#define YYMAJOR 1 +#define YYMINOR 9 +#define yyclearin (yychar=(-1)) +#define yyerrok (yyerrflag=0) +#define YYRECOVERING (yyerrflag!=0) +#define YYPREFIX "yy" +#define YYERRCODE 256 +short yylhs[] = { -1, + 0, +}; +short yylen[] = { 2, + 1, +}; +short yydefred[] = { 0, + 1, 0, +}; +short yydgoto[] = { 2, +}; +short yysindex[] = { -256, + 0, 0, +}; +short yyrindex[] = { 0, + 0, 0, +}; +short yygindex[] = { 0, +}; +#define YYTABLESIZE 0 +short yytable[] = { 1, +}; +short yycheck[] = { 256, +}; +#define YYFINAL 2 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 0 +#if YYDEBUG +char *yyname[] = { +"end-of-file", +}; +char *yyrule[] = { +"$accept : S", +"S : error", +}; +#endif +#ifndef YYSTYPE +typedef int YYSTYPE; +#endif +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 500 +#define YYMAXDEPTH 500 +#endif +#endif +int yydebug; +int yynerrs; +int yyerrflag; +int yychar; +short *yyssp; +YYSTYPE *yyvsp; +YYSTYPE yyval; +YYSTYPE yylval; +short yyss[YYSTACKSIZE]; +YYSTYPE yyvs[YYSTACKSIZE]; +#define yystacksize YYSTACKSIZE +#line 4 "error.y" +main(){printf("yyparse() = %d\n",yyparse());} +yylex(){return-1;} +yyerror(s)char*s;{printf("%s\n",s);} +#line 80 "error.tab.c" +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +int +yyparse() +{ + register int yym, yyn, yystate; +#if YYDEBUG + register char *yys; + extern char *getenv(); + + if (yys = getenv("YYDEBUG")) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } +#endif + + yynerrs = 0; + yyerrflag = 0; + yychar = (-1); + + yyssp = yyss; + yyvsp = yyvs; + *yyssp = yystate = 0; + +yyloop: + if (yyn = yydefred[yystate]) goto yyreduce; + if (yychar < 0) + { + if ((yychar = yylex()) < 0) yychar = 0; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yyssp >= yyss + yystacksize - 1) + { + goto yyoverflow; + } + *++yyssp = yystate = yytable[yyn]; + *++yyvsp = yylval; + yychar = (-1); + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag) goto yyinrecovery; +#ifdef lint + goto yynewerror; +#endif +yynewerror: + yyerror("syntax error"); +#ifdef lint + goto yyerrlab; +#endif +yyerrlab: + ++yynerrs; +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yyssp, yytable[yyn]); +#endif + if (yyssp >= yyss + yystacksize - 1) + { + goto yyoverflow; + } + *++yyssp = yystate = yytable[yyn]; + *++yyvsp = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yyssp); +#endif + if (yyssp <= yyss) goto yyabort; + --yyssp; + --yyvsp; + } + } + } + else + { + if (yychar == 0) goto yyabort; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = (-1); + goto yyloop; + } +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + yyval = yyvsp[1-yym]; + switch (yyn) + { + } + yyssp -= yym; + yystate = *yyssp; + yyvsp -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yyssp = YYFINAL; + *++yyvsp = yyval; + if (yychar < 0) + { + if ((yychar = yylex()) < 0) yychar = 0; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == 0) goto yyaccept; + goto yyloop; + } + if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yyssp, yystate); +#endif + if (yyssp >= yyss + yystacksize - 1) + { + goto yyoverflow; + } + *++yyssp = yystate; + *++yyvsp = yyval; + goto yyloop; +yyoverflow: + yyerror("yacc stack overflow"); +yyabort: + return (1); +yyaccept: + return (0); +} diff --git a/commands/yacc/test/error.tab.h b/commands/yacc/test/error.tab.h new file mode 100644 index 000000000..793c5dbc6 --- /dev/null +++ b/commands/yacc/test/error.tab.h @@ -0,0 +1,2 @@ +/* $NetBSD: error.tab.h,v 1.2 1998/01/09 08:08:55 perry Exp $ */ + diff --git a/commands/yacc/test/error.y b/commands/yacc/test/error.y new file mode 100644 index 000000000..41148ea92 --- /dev/null +++ b/commands/yacc/test/error.y @@ -0,0 +1,6 @@ +%% +S: error +%% +main(){printf("yyparse() = %d\n",yyparse());} +yylex(){return-1;} +yyerror(s)char*s;{printf("%s\n",s);} diff --git a/commands/yacc/test/ftp.output b/commands/yacc/test/ftp.output new file mode 100644 index 000000000..f1ab4b298 --- /dev/null +++ b/commands/yacc/test/ftp.output @@ -0,0 +1,1625 @@ + 0 $accept : cmd_list $end + + 1 cmd_list : + 2 | cmd_list cmd + 3 | cmd_list rcmd + + 4 cmd : USER SP username CRLF + 5 | PASS SP password CRLF + 6 | PORT SP host_port CRLF + 7 | PASV CRLF + 8 | TYPE SP type_code CRLF + 9 | STRU SP struct_code CRLF + 10 | MODE SP mode_code CRLF + 11 | ALLO SP NUMBER CRLF + 12 | ALLO SP NUMBER SP R SP NUMBER CRLF + 13 | RETR check_login SP pathname CRLF + 14 | STOR check_login SP pathname CRLF + 15 | APPE check_login SP pathname CRLF + 16 | NLST check_login CRLF + 17 | NLST check_login SP STRING CRLF + 18 | LIST check_login CRLF + 19 | LIST check_login SP pathname CRLF + 20 | STAT check_login SP pathname CRLF + 21 | STAT CRLF + 22 | DELE check_login SP pathname CRLF + 23 | RNTO SP pathname CRLF + 24 | ABOR CRLF + 25 | CWD check_login CRLF + 26 | CWD check_login SP pathname CRLF + 27 | HELP CRLF + 28 | HELP SP STRING CRLF + 29 | NOOP CRLF + 30 | MKD check_login SP pathname CRLF + 31 | RMD check_login SP pathname CRLF + 32 | PWD check_login CRLF + 33 | CDUP check_login CRLF + 34 | SITE SP HELP CRLF + 35 | SITE SP HELP SP STRING CRLF + 36 | SITE SP UMASK check_login CRLF + 37 | SITE SP UMASK check_login SP octal_number CRLF + 38 | SITE SP CHMOD check_login SP octal_number SP pathname CRLF + 39 | SITE SP IDLE CRLF + 40 | SITE SP IDLE SP NUMBER CRLF + 41 | STOU check_login SP pathname CRLF + 42 | SYST CRLF + 43 | SIZE check_login SP pathname CRLF + 44 | MDTM check_login SP pathname CRLF + 45 | QUIT CRLF + 46 | error CRLF + + 47 rcmd : RNFR check_login SP pathname CRLF + + 48 username : STRING + + 49 password : + 50 | STRING + + 51 byte_size : NUMBER + + 52 host_port : NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER + + 53 form_code : N + 54 | T + 55 | C + + 56 type_code : A + 57 | A SP form_code + 58 | E + 59 | E SP form_code + 60 | I + 61 | L + 62 | L SP byte_size + 63 | L byte_size + + 64 struct_code : F + 65 | R + 66 | P + + 67 mode_code : S + 68 | B + 69 | C + + 70 pathname : pathstring + + 71 pathstring : STRING + + 72 octal_number : NUMBER + + 73 check_login : + +state 0 + $accept : . cmd_list $end (0) + cmd_list : . (1) + + . reduce 1 + + cmd_list goto 1 + + +state 1 + $accept : cmd_list . $end (0) + cmd_list : cmd_list . cmd (2) + cmd_list : cmd_list . rcmd (3) + + $end accept + error shift 2 + USER shift 3 + PASS shift 4 + QUIT shift 5 + PORT shift 6 + PASV shift 7 + TYPE shift 8 + STRU shift 9 + MODE shift 10 + RETR shift 11 + STOR shift 12 + APPE shift 13 + ALLO shift 14 + RNFR shift 15 + RNTO shift 16 + ABOR shift 17 + DELE shift 18 + CWD shift 19 + LIST shift 20 + NLST shift 21 + SITE shift 22 + STAT shift 23 + HELP shift 24 + NOOP shift 25 + MKD shift 26 + RMD shift 27 + PWD shift 28 + CDUP shift 29 + STOU shift 30 + SYST shift 31 + SIZE shift 32 + MDTM shift 33 + . error + + cmd goto 34 + rcmd goto 35 + + +state 2 + cmd : error . CRLF (46) + + CRLF shift 36 + . error + + +state 3 + cmd : USER . SP username CRLF (4) + + SP shift 37 + . error + + +state 4 + cmd : PASS . SP password CRLF (5) + + SP shift 38 + . error + + +state 5 + cmd : QUIT . CRLF (45) + + CRLF shift 39 + . error + + +state 6 + cmd : PORT . SP host_port CRLF (6) + + SP shift 40 + . error + + +state 7 + cmd : PASV . CRLF (7) + + CRLF shift 41 + . error + + +state 8 + cmd : TYPE . SP type_code CRLF (8) + + SP shift 42 + . error + + +state 9 + cmd : STRU . SP struct_code CRLF (9) + + SP shift 43 + . error + + +state 10 + cmd : MODE . SP mode_code CRLF (10) + + SP shift 44 + . error + + +state 11 + cmd : RETR . check_login SP pathname CRLF (13) + check_login : . (73) + + . reduce 73 + + check_login goto 45 + + +state 12 + cmd : STOR . check_login SP pathname CRLF (14) + check_login : . (73) + + . reduce 73 + + check_login goto 46 + + +state 13 + cmd : APPE . check_login SP pathname CRLF (15) + check_login : . (73) + + . reduce 73 + + check_login goto 47 + + +state 14 + cmd : ALLO . SP NUMBER CRLF (11) + cmd : ALLO . SP NUMBER SP R SP NUMBER CRLF (12) + + SP shift 48 + . error + + +state 15 + rcmd : RNFR . check_login SP pathname CRLF (47) + check_login : . (73) + + . reduce 73 + + check_login goto 49 + + +state 16 + cmd : RNTO . SP pathname CRLF (23) + + SP shift 50 + . error + + +state 17 + cmd : ABOR . CRLF (24) + + CRLF shift 51 + . error + + +state 18 + cmd : DELE . check_login SP pathname CRLF (22) + check_login : . (73) + + . reduce 73 + + check_login goto 52 + + +state 19 + cmd : CWD . check_login CRLF (25) + cmd : CWD . check_login SP pathname CRLF (26) + check_login : . (73) + + . reduce 73 + + check_login goto 53 + + +state 20 + cmd : LIST . check_login CRLF (18) + cmd : LIST . check_login SP pathname CRLF (19) + check_login : . (73) + + . reduce 73 + + check_login goto 54 + + +state 21 + cmd : NLST . check_login CRLF (16) + cmd : NLST . check_login SP STRING CRLF (17) + check_login : . (73) + + . reduce 73 + + check_login goto 55 + + +state 22 + cmd : SITE . SP HELP CRLF (34) + cmd : SITE . SP HELP SP STRING CRLF (35) + cmd : SITE . SP UMASK check_login CRLF (36) + cmd : SITE . SP UMASK check_login SP octal_number CRLF (37) + cmd : SITE . SP CHMOD check_login SP octal_number SP pathname CRLF (38) + cmd : SITE . SP IDLE CRLF (39) + cmd : SITE . SP IDLE SP NUMBER CRLF (40) + + SP shift 56 + . error + + +state 23 + cmd : STAT . check_login SP pathname CRLF (20) + cmd : STAT . CRLF (21) + check_login : . (73) + + CRLF shift 57 + SP reduce 73 + + check_login goto 58 + + +state 24 + cmd : HELP . CRLF (27) + cmd : HELP . SP STRING CRLF (28) + + SP shift 59 + CRLF shift 60 + . error + + +state 25 + cmd : NOOP . CRLF (29) + + CRLF shift 61 + . error + + +state 26 + cmd : MKD . check_login SP pathname CRLF (30) + check_login : . (73) + + . reduce 73 + + check_login goto 62 + + +state 27 + cmd : RMD . check_login SP pathname CRLF (31) + check_login : . (73) + + . reduce 73 + + check_login goto 63 + + +state 28 + cmd : PWD . check_login CRLF (32) + check_login : . (73) + + . reduce 73 + + check_login goto 64 + + +state 29 + cmd : CDUP . check_login CRLF (33) + check_login : . (73) + + . reduce 73 + + check_login goto 65 + + +state 30 + cmd : STOU . check_login SP pathname CRLF (41) + check_login : . (73) + + . reduce 73 + + check_login goto 66 + + +state 31 + cmd : SYST . CRLF (42) + + CRLF shift 67 + . error + + +state 32 + cmd : SIZE . check_login SP pathname CRLF (43) + check_login : . (73) + + . reduce 73 + + check_login goto 68 + + +state 33 + cmd : MDTM . check_login SP pathname CRLF (44) + check_login : . (73) + + . reduce 73 + + check_login goto 69 + + +state 34 + cmd_list : cmd_list cmd . (2) + + . reduce 2 + + +state 35 + cmd_list : cmd_list rcmd . (3) + + . reduce 3 + + +state 36 + cmd : error CRLF . (46) + + . reduce 46 + + +state 37 + cmd : USER SP . username CRLF (4) + + STRING shift 70 + . error + + username goto 71 + + +state 38 + cmd : PASS SP . password CRLF (5) + password : . (49) + + STRING shift 72 + CRLF reduce 49 + + password goto 73 + + +state 39 + cmd : QUIT CRLF . (45) + + . reduce 45 + + +state 40 + cmd : PORT SP . host_port CRLF (6) + + NUMBER shift 74 + . error + + host_port goto 75 + + +state 41 + cmd : PASV CRLF . (7) + + . reduce 7 + + +state 42 + cmd : TYPE SP . type_code CRLF (8) + + A shift 76 + E shift 77 + I shift 78 + L shift 79 + . error + + type_code goto 80 + + +state 43 + cmd : STRU SP . struct_code CRLF (9) + + F shift 81 + P shift 82 + R shift 83 + . error + + struct_code goto 84 + + +state 44 + cmd : MODE SP . mode_code CRLF (10) + + B shift 85 + C shift 86 + S shift 87 + . error + + mode_code goto 88 + + +state 45 + cmd : RETR check_login . SP pathname CRLF (13) + + SP shift 89 + . error + + +state 46 + cmd : STOR check_login . SP pathname CRLF (14) + + SP shift 90 + . error + + +state 47 + cmd : APPE check_login . SP pathname CRLF (15) + + SP shift 91 + . error + + +state 48 + cmd : ALLO SP . NUMBER CRLF (11) + cmd : ALLO SP . NUMBER SP R SP NUMBER CRLF (12) + + NUMBER shift 92 + . error + + +state 49 + rcmd : RNFR check_login . SP pathname CRLF (47) + + SP shift 93 + . error + + +state 50 + cmd : RNTO SP . pathname CRLF (23) + + STRING shift 94 + . error + + pathname goto 95 + pathstring goto 96 + + +state 51 + cmd : ABOR CRLF . (24) + + . reduce 24 + + +state 52 + cmd : DELE check_login . SP pathname CRLF (22) + + SP shift 97 + . error + + +state 53 + cmd : CWD check_login . CRLF (25) + cmd : CWD check_login . SP pathname CRLF (26) + + SP shift 98 + CRLF shift 99 + . error + + +state 54 + cmd : LIST check_login . CRLF (18) + cmd : LIST check_login . SP pathname CRLF (19) + + SP shift 100 + CRLF shift 101 + . error + + +state 55 + cmd : NLST check_login . CRLF (16) + cmd : NLST check_login . SP STRING CRLF (17) + + SP shift 102 + CRLF shift 103 + . error + + +state 56 + cmd : SITE SP . HELP CRLF (34) + cmd : SITE SP . HELP SP STRING CRLF (35) + cmd : SITE SP . UMASK check_login CRLF (36) + cmd : SITE SP . UMASK check_login SP octal_number CRLF (37) + cmd : SITE SP . CHMOD check_login SP octal_number SP pathname CRLF (38) + cmd : SITE SP . IDLE CRLF (39) + cmd : SITE SP . IDLE SP NUMBER CRLF (40) + + HELP shift 104 + UMASK shift 105 + IDLE shift 106 + CHMOD shift 107 + . error + + +state 57 + cmd : STAT CRLF . (21) + + . reduce 21 + + +state 58 + cmd : STAT check_login . SP pathname CRLF (20) + + SP shift 108 + . error + + +state 59 + cmd : HELP SP . STRING CRLF (28) + + STRING shift 109 + . error + + +state 60 + cmd : HELP CRLF . (27) + + . reduce 27 + + +state 61 + cmd : NOOP CRLF . (29) + + . reduce 29 + + +state 62 + cmd : MKD check_login . SP pathname CRLF (30) + + SP shift 110 + . error + + +state 63 + cmd : RMD check_login . SP pathname CRLF (31) + + SP shift 111 + . error + + +state 64 + cmd : PWD check_login . CRLF (32) + + CRLF shift 112 + . error + + +state 65 + cmd : CDUP check_login . CRLF (33) + + CRLF shift 113 + . error + + +state 66 + cmd : STOU check_login . SP pathname CRLF (41) + + SP shift 114 + . error + + +state 67 + cmd : SYST CRLF . (42) + + . reduce 42 + + +state 68 + cmd : SIZE check_login . SP pathname CRLF (43) + + SP shift 115 + . error + + +state 69 + cmd : MDTM check_login . SP pathname CRLF (44) + + SP shift 116 + . error + + +state 70 + username : STRING . (48) + + . reduce 48 + + +state 71 + cmd : USER SP username . CRLF (4) + + CRLF shift 117 + . error + + +state 72 + password : STRING . (50) + + . reduce 50 + + +state 73 + cmd : PASS SP password . CRLF (5) + + CRLF shift 118 + . error + + +state 74 + host_port : NUMBER . COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER (52) + + COMMA shift 119 + . error + + +state 75 + cmd : PORT SP host_port . CRLF (6) + + CRLF shift 120 + . error + + +state 76 + type_code : A . (56) + type_code : A . SP form_code (57) + + SP shift 121 + CRLF reduce 56 + + +state 77 + type_code : E . (58) + type_code : E . SP form_code (59) + + SP shift 122 + CRLF reduce 58 + + +state 78 + type_code : I . (60) + + . reduce 60 + + +state 79 + type_code : L . (61) + type_code : L . SP byte_size (62) + type_code : L . byte_size (63) + + SP shift 123 + NUMBER shift 124 + CRLF reduce 61 + + byte_size goto 125 + + +state 80 + cmd : TYPE SP type_code . CRLF (8) + + CRLF shift 126 + . error + + +state 81 + struct_code : F . (64) + + . reduce 64 + + +state 82 + struct_code : P . (66) + + . reduce 66 + + +state 83 + struct_code : R . (65) + + . reduce 65 + + +state 84 + cmd : STRU SP struct_code . CRLF (9) + + CRLF shift 127 + . error + + +state 85 + mode_code : B . (68) + + . reduce 68 + + +state 86 + mode_code : C . (69) + + . reduce 69 + + +state 87 + mode_code : S . (67) + + . reduce 67 + + +state 88 + cmd : MODE SP mode_code . CRLF (10) + + CRLF shift 128 + . error + + +state 89 + cmd : RETR check_login SP . pathname CRLF (13) + + STRING shift 94 + . error + + pathname goto 129 + pathstring goto 96 + + +state 90 + cmd : STOR check_login SP . pathname CRLF (14) + + STRING shift 94 + . error + + pathname goto 130 + pathstring goto 96 + + +state 91 + cmd : APPE check_login SP . pathname CRLF (15) + + STRING shift 94 + . error + + pathname goto 131 + pathstring goto 96 + + +state 92 + cmd : ALLO SP NUMBER . CRLF (11) + cmd : ALLO SP NUMBER . SP R SP NUMBER CRLF (12) + + SP shift 132 + CRLF shift 133 + . error + + +state 93 + rcmd : RNFR check_login SP . pathname CRLF (47) + + STRING shift 94 + . error + + pathname goto 134 + pathstring goto 96 + + +state 94 + pathstring : STRING . (71) + + . reduce 71 + + +state 95 + cmd : RNTO SP pathname . CRLF (23) + + CRLF shift 135 + . error + + +state 96 + pathname : pathstring . (70) + + . reduce 70 + + +state 97 + cmd : DELE check_login SP . pathname CRLF (22) + + STRING shift 94 + . error + + pathname goto 136 + pathstring goto 96 + + +state 98 + cmd : CWD check_login SP . pathname CRLF (26) + + STRING shift 94 + . error + + pathname goto 137 + pathstring goto 96 + + +state 99 + cmd : CWD check_login CRLF . (25) + + . reduce 25 + + +state 100 + cmd : LIST check_login SP . pathname CRLF (19) + + STRING shift 94 + . error + + pathname goto 138 + pathstring goto 96 + + +state 101 + cmd : LIST check_login CRLF . (18) + + . reduce 18 + + +state 102 + cmd : NLST check_login SP . STRING CRLF (17) + + STRING shift 139 + . error + + +state 103 + cmd : NLST check_login CRLF . (16) + + . reduce 16 + + +state 104 + cmd : SITE SP HELP . CRLF (34) + cmd : SITE SP HELP . SP STRING CRLF (35) + + SP shift 140 + CRLF shift 141 + . error + + +state 105 + cmd : SITE SP UMASK . check_login CRLF (36) + cmd : SITE SP UMASK . check_login SP octal_number CRLF (37) + check_login : . (73) + + . reduce 73 + + check_login goto 142 + + +state 106 + cmd : SITE SP IDLE . CRLF (39) + cmd : SITE SP IDLE . SP NUMBER CRLF (40) + + SP shift 143 + CRLF shift 144 + . error + + +state 107 + cmd : SITE SP CHMOD . check_login SP octal_number SP pathname CRLF (38) + check_login : . (73) + + . reduce 73 + + check_login goto 145 + + +state 108 + cmd : STAT check_login SP . pathname CRLF (20) + + STRING shift 94 + . error + + pathname goto 146 + pathstring goto 96 + + +state 109 + cmd : HELP SP STRING . CRLF (28) + + CRLF shift 147 + . error + + +state 110 + cmd : MKD check_login SP . pathname CRLF (30) + + STRING shift 94 + . error + + pathname goto 148 + pathstring goto 96 + + +state 111 + cmd : RMD check_login SP . pathname CRLF (31) + + STRING shift 94 + . error + + pathname goto 149 + pathstring goto 96 + + +state 112 + cmd : PWD check_login CRLF . (32) + + . reduce 32 + + +state 113 + cmd : CDUP check_login CRLF . (33) + + . reduce 33 + + +state 114 + cmd : STOU check_login SP . pathname CRLF (41) + + STRING shift 94 + . error + + pathname goto 150 + pathstring goto 96 + + +state 115 + cmd : SIZE check_login SP . pathname CRLF (43) + + STRING shift 94 + . error + + pathname goto 151 + pathstring goto 96 + + +state 116 + cmd : MDTM check_login SP . pathname CRLF (44) + + STRING shift 94 + . error + + pathname goto 152 + pathstring goto 96 + + +state 117 + cmd : USER SP username CRLF . (4) + + . reduce 4 + + +state 118 + cmd : PASS SP password CRLF . (5) + + . reduce 5 + + +state 119 + host_port : NUMBER COMMA . NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER (52) + + NUMBER shift 153 + . error + + +state 120 + cmd : PORT SP host_port CRLF . (6) + + . reduce 6 + + +state 121 + type_code : A SP . form_code (57) + + C shift 154 + N shift 155 + T shift 156 + . error + + form_code goto 157 + + +state 122 + type_code : E SP . form_code (59) + + C shift 154 + N shift 155 + T shift 156 + . error + + form_code goto 158 + + +state 123 + type_code : L SP . byte_size (62) + + NUMBER shift 124 + . error + + byte_size goto 159 + + +state 124 + byte_size : NUMBER . (51) + + . reduce 51 + + +state 125 + type_code : L byte_size . (63) + + . reduce 63 + + +state 126 + cmd : TYPE SP type_code CRLF . (8) + + . reduce 8 + + +state 127 + cmd : STRU SP struct_code CRLF . (9) + + . reduce 9 + + +state 128 + cmd : MODE SP mode_code CRLF . (10) + + . reduce 10 + + +state 129 + cmd : RETR check_login SP pathname . CRLF (13) + + CRLF shift 160 + . error + + +state 130 + cmd : STOR check_login SP pathname . CRLF (14) + + CRLF shift 161 + . error + + +state 131 + cmd : APPE check_login SP pathname . CRLF (15) + + CRLF shift 162 + . error + + +state 132 + cmd : ALLO SP NUMBER SP . R SP NUMBER CRLF (12) + + R shift 163 + . error + + +state 133 + cmd : ALLO SP NUMBER CRLF . (11) + + . reduce 11 + + +state 134 + rcmd : RNFR check_login SP pathname . CRLF (47) + + CRLF shift 164 + . error + + +state 135 + cmd : RNTO SP pathname CRLF . (23) + + . reduce 23 + + +state 136 + cmd : DELE check_login SP pathname . CRLF (22) + + CRLF shift 165 + . error + + +state 137 + cmd : CWD check_login SP pathname . CRLF (26) + + CRLF shift 166 + . error + + +state 138 + cmd : LIST check_login SP pathname . CRLF (19) + + CRLF shift 167 + . error + + +state 139 + cmd : NLST check_login SP STRING . CRLF (17) + + CRLF shift 168 + . error + + +state 140 + cmd : SITE SP HELP SP . STRING CRLF (35) + + STRING shift 169 + . error + + +state 141 + cmd : SITE SP HELP CRLF . (34) + + . reduce 34 + + +state 142 + cmd : SITE SP UMASK check_login . CRLF (36) + cmd : SITE SP UMASK check_login . SP octal_number CRLF (37) + + SP shift 170 + CRLF shift 171 + . error + + +state 143 + cmd : SITE SP IDLE SP . NUMBER CRLF (40) + + NUMBER shift 172 + . error + + +state 144 + cmd : SITE SP IDLE CRLF . (39) + + . reduce 39 + + +state 145 + cmd : SITE SP CHMOD check_login . SP octal_number SP pathname CRLF (38) + + SP shift 173 + . error + + +state 146 + cmd : STAT check_login SP pathname . CRLF (20) + + CRLF shift 174 + . error + + +state 147 + cmd : HELP SP STRING CRLF . (28) + + . reduce 28 + + +state 148 + cmd : MKD check_login SP pathname . CRLF (30) + + CRLF shift 175 + . error + + +state 149 + cmd : RMD check_login SP pathname . CRLF (31) + + CRLF shift 176 + . error + + +state 150 + cmd : STOU check_login SP pathname . CRLF (41) + + CRLF shift 177 + . error + + +state 151 + cmd : SIZE check_login SP pathname . CRLF (43) + + CRLF shift 178 + . error + + +state 152 + cmd : MDTM check_login SP pathname . CRLF (44) + + CRLF shift 179 + . error + + +state 153 + host_port : NUMBER COMMA NUMBER . COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER (52) + + COMMA shift 180 + . error + + +state 154 + form_code : C . (55) + + . reduce 55 + + +state 155 + form_code : N . (53) + + . reduce 53 + + +state 156 + form_code : T . (54) + + . reduce 54 + + +state 157 + type_code : A SP form_code . (57) + + . reduce 57 + + +state 158 + type_code : E SP form_code . (59) + + . reduce 59 + + +state 159 + type_code : L SP byte_size . (62) + + . reduce 62 + + +state 160 + cmd : RETR check_login SP pathname CRLF . (13) + + . reduce 13 + + +state 161 + cmd : STOR check_login SP pathname CRLF . (14) + + . reduce 14 + + +state 162 + cmd : APPE check_login SP pathname CRLF . (15) + + . reduce 15 + + +state 163 + cmd : ALLO SP NUMBER SP R . SP NUMBER CRLF (12) + + SP shift 181 + . error + + +state 164 + rcmd : RNFR check_login SP pathname CRLF . (47) + + . reduce 47 + + +state 165 + cmd : DELE check_login SP pathname CRLF . (22) + + . reduce 22 + + +state 166 + cmd : CWD check_login SP pathname CRLF . (26) + + . reduce 26 + + +state 167 + cmd : LIST check_login SP pathname CRLF . (19) + + . reduce 19 + + +state 168 + cmd : NLST check_login SP STRING CRLF . (17) + + . reduce 17 + + +state 169 + cmd : SITE SP HELP SP STRING . CRLF (35) + + CRLF shift 182 + . error + + +state 170 + cmd : SITE SP UMASK check_login SP . octal_number CRLF (37) + + NUMBER shift 183 + . error + + octal_number goto 184 + + +state 171 + cmd : SITE SP UMASK check_login CRLF . (36) + + . reduce 36 + + +state 172 + cmd : SITE SP IDLE SP NUMBER . CRLF (40) + + CRLF shift 185 + . error + + +state 173 + cmd : SITE SP CHMOD check_login SP . octal_number SP pathname CRLF (38) + + NUMBER shift 183 + . error + + octal_number goto 186 + + +state 174 + cmd : STAT check_login SP pathname CRLF . (20) + + . reduce 20 + + +state 175 + cmd : MKD check_login SP pathname CRLF . (30) + + . reduce 30 + + +state 176 + cmd : RMD check_login SP pathname CRLF . (31) + + . reduce 31 + + +state 177 + cmd : STOU check_login SP pathname CRLF . (41) + + . reduce 41 + + +state 178 + cmd : SIZE check_login SP pathname CRLF . (43) + + . reduce 43 + + +state 179 + cmd : MDTM check_login SP pathname CRLF . (44) + + . reduce 44 + + +state 180 + host_port : NUMBER COMMA NUMBER COMMA . NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER (52) + + NUMBER shift 187 + . error + + +state 181 + cmd : ALLO SP NUMBER SP R SP . NUMBER CRLF (12) + + NUMBER shift 188 + . error + + +state 182 + cmd : SITE SP HELP SP STRING CRLF . (35) + + . reduce 35 + + +state 183 + octal_number : NUMBER . (72) + + . reduce 72 + + +state 184 + cmd : SITE SP UMASK check_login SP octal_number . CRLF (37) + + CRLF shift 189 + . error + + +state 185 + cmd : SITE SP IDLE SP NUMBER CRLF . (40) + + . reduce 40 + + +state 186 + cmd : SITE SP CHMOD check_login SP octal_number . SP pathname CRLF (38) + + SP shift 190 + . error + + +state 187 + host_port : NUMBER COMMA NUMBER COMMA NUMBER . COMMA NUMBER COMMA NUMBER COMMA NUMBER (52) + + COMMA shift 191 + . error + + +state 188 + cmd : ALLO SP NUMBER SP R SP NUMBER . CRLF (12) + + CRLF shift 192 + . error + + +state 189 + cmd : SITE SP UMASK check_login SP octal_number CRLF . (37) + + . reduce 37 + + +state 190 + cmd : SITE SP CHMOD check_login SP octal_number SP . pathname CRLF (38) + + STRING shift 94 + . error + + pathname goto 193 + pathstring goto 96 + + +state 191 + host_port : NUMBER COMMA NUMBER COMMA NUMBER COMMA . NUMBER COMMA NUMBER COMMA NUMBER (52) + + NUMBER shift 194 + . error + + +state 192 + cmd : ALLO SP NUMBER SP R SP NUMBER CRLF . (12) + + . reduce 12 + + +state 193 + cmd : SITE SP CHMOD check_login SP octal_number SP pathname . CRLF (38) + + CRLF shift 195 + . error + + +state 194 + host_port : NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER . COMMA NUMBER COMMA NUMBER (52) + + COMMA shift 196 + . error + + +state 195 + cmd : SITE SP CHMOD check_login SP octal_number SP pathname CRLF . (38) + + . reduce 38 + + +state 196 + host_port : NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA . NUMBER COMMA NUMBER (52) + + NUMBER shift 197 + . error + + +state 197 + host_port : NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER . COMMA NUMBER (52) + + COMMA shift 198 + . error + + +state 198 + host_port : NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA . NUMBER (52) + + NUMBER shift 199 + . error + + +state 199 + host_port : NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER . (52) + + . reduce 52 + + +65 terminals, 16 nonterminals +74 grammar rules, 200 states diff --git a/commands/yacc/test/ftp.tab.c b/commands/yacc/test/ftp.tab.c new file mode 100644 index 000000000..9d9317f4c --- /dev/null +++ b/commands/yacc/test/ftp.tab.c @@ -0,0 +1,1745 @@ +#ifndef lint +/*static char yysccsid[] = "from: @(#)yaccpar 1.9 (Berkeley) 02/21/93";*/ +static char rcsid[] = "$NetBSD: ftp.tab.c,v 1.7 2001/01/04 23:05:57 lukem Exp $"; +#endif +#define YYBYACC 1 +#define YYMAJOR 1 +#define YYMINOR 9 +#define yyclearin (yychar=(-1)) +#define yyerrok (yyerrflag=0) +#define YYRECOVERING (yyerrflag!=0) +#define YYPREFIX "yy" +#line 26 "ftp.y" + +#ifndef lint +static char sccsid[] = "@(#)ftpcmd.y 5.20.1.1 (Berkeley) 3/2/89"; +#endif /* not lint */ + +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +extern struct sockaddr_in data_dest; +extern int logged_in; +extern struct passwd *pw; +extern int guest; +extern int logging; +extern int type; +extern int form; +extern int debug; +extern int timeout; +extern int maxtimeout; +extern int pdata; +extern char hostname[], remotehost[]; +extern char proctitle[]; +extern char *globerr; +extern int usedefault; +extern int transflag; +extern char tmpline[]; +char **glob(); + +static int cmd_type; +static int cmd_form; +static int cmd_bytesz; +char cbuf[512]; +char *fromname; + +char *index(); +#line 60 "ftp.tab.c" +#define A 257 +#define B 258 +#define C 259 +#define E 260 +#define F 261 +#define I 262 +#define L 263 +#define N 264 +#define P 265 +#define R 266 +#define S 267 +#define T 268 +#define SP 269 +#define CRLF 270 +#define COMMA 271 +#define STRING 272 +#define NUMBER 273 +#define USER 274 +#define PASS 275 +#define ACCT 276 +#define REIN 277 +#define QUIT 278 +#define PORT 279 +#define PASV 280 +#define TYPE 281 +#define STRU 282 +#define MODE 283 +#define RETR 284 +#define STOR 285 +#define APPE 286 +#define MLFL 287 +#define MAIL 288 +#define MSND 289 +#define MSOM 290 +#define MSAM 291 +#define MRSQ 292 +#define MRCP 293 +#define ALLO 294 +#define REST 295 +#define RNFR 296 +#define RNTO 297 +#define ABOR 298 +#define DELE 299 +#define CWD 300 +#define LIST 301 +#define NLST 302 +#define SITE 303 +#define STAT 304 +#define HELP 305 +#define NOOP 306 +#define MKD 307 +#define RMD 308 +#define PWD 309 +#define CDUP 310 +#define STOU 311 +#define SMNT 312 +#define SYST 313 +#define SIZE 314 +#define MDTM 315 +#define UMASK 316 +#define IDLE 317 +#define CHMOD 318 +#define LEXERR 319 +#define YYERRCODE 256 +short yylhs[] = { -1, + 0, 0, 0, 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, 2, 3, 4, 4, + 12, 5, 13, 13, 13, 6, 6, 6, 6, 6, + 6, 6, 6, 7, 7, 7, 8, 8, 8, 10, + 14, 11, 9, +}; +short yylen[] = { 2, + 0, 2, 2, 4, 4, 4, 2, 4, 4, 4, + 4, 8, 5, 5, 5, 3, 5, 3, 5, 5, + 2, 5, 4, 2, 3, 5, 2, 4, 2, 5, + 5, 3, 3, 4, 6, 5, 7, 9, 4, 6, + 5, 2, 5, 5, 2, 2, 5, 1, 0, 1, + 1, 11, 1, 1, 1, 1, 3, 1, 3, 1, + 1, 3, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 0, +}; +short yydefred[] = { 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 73, 73, 73, 0, 73, 0, 0, 73, 73, 73, + 73, 0, 0, 0, 0, 73, 73, 73, 73, 73, + 0, 73, 73, 2, 3, 46, 0, 0, 45, 0, + 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 24, 0, 0, 0, 0, 0, 21, 0, 0, 27, + 29, 0, 0, 0, 0, 0, 42, 0, 0, 48, + 0, 50, 0, 0, 0, 0, 0, 60, 0, 0, + 64, 66, 65, 0, 68, 69, 67, 0, 0, 0, + 0, 0, 0, 71, 0, 70, 0, 0, 25, 0, + 18, 0, 16, 0, 73, 0, 73, 0, 0, 0, + 0, 32, 33, 0, 0, 0, 4, 5, 0, 6, + 0, 0, 0, 51, 63, 8, 9, 10, 0, 0, + 0, 0, 11, 0, 23, 0, 0, 0, 0, 0, + 34, 0, 0, 39, 0, 0, 28, 0, 0, 0, + 0, 0, 0, 55, 53, 54, 57, 59, 62, 13, + 14, 15, 0, 47, 22, 26, 19, 17, 0, 0, + 36, 0, 0, 20, 30, 31, 41, 43, 44, 0, + 0, 35, 72, 0, 40, 0, 0, 0, 37, 0, + 0, 12, 0, 0, 38, 0, 0, 0, 52, +}; +short yydgoto[] = { 1, + 34, 35, 71, 73, 75, 80, 84, 88, 45, 95, + 184, 125, 157, 96, +}; +short yysindex[] = { 0, + -224, -247, -239, -236, -232, -222, -204, -200, -181, -177, + 0, 0, 0, -166, 0, -161, -199, 0, 0, 0, + 0, -160, -159, -264, -158, 0, 0, 0, 0, 0, + -157, 0, 0, 0, 0, 0, -167, -162, 0, -156, + 0, -250, -198, -165, -155, -154, -153, -151, -150, -152, + 0, -145, -252, -229, -217, -302, 0, -144, -146, 0, + 0, -142, -141, -140, -139, -137, 0, -136, -135, 0, + -134, 0, -133, -132, -130, -131, -128, 0, -249, -127, + 0, 0, 0, -126, 0, 0, 0, -125, -152, -152, + -152, -205, -152, 0, -124, 0, -152, -152, 0, -152, + 0, -143, 0, -173, 0, -171, 0, -152, -123, -152, + -152, 0, 0, -152, -152, -152, 0, 0, -138, 0, + -164, -164, -122, 0, 0, 0, 0, 0, -121, -120, + -118, -148, 0, -117, 0, -116, -115, -114, -113, -112, + 0, -163, -111, 0, -110, -109, 0, -107, -106, -105, + -104, -103, -129, 0, 0, 0, 0, 0, 0, 0, + 0, 0, -101, 0, 0, 0, 0, 0, -100, -102, + 0, -98, -102, 0, 0, 0, 0, 0, 0, -99, + -97, 0, 0, -95, 0, -96, -94, -92, 0, -152, + -93, 0, -91, -90, 0, -88, -87, -86, 0, +}; +short yyrindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, -83, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -82, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, -81, -80, 0, -158, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; +short yygindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 16, -89, + -25, 35, 47, 0, +}; +#define YYTABLESIZE 190 +short yytable[] = { 129, + 130, 131, 104, 134, 59, 60, 76, 136, 137, 77, + 138, 78, 79, 105, 106, 107, 98, 99, 146, 123, + 148, 149, 36, 124, 150, 151, 152, 46, 47, 37, + 49, 2, 38, 52, 53, 54, 55, 39, 58, 100, + 101, 62, 63, 64, 65, 66, 40, 68, 69, 3, + 4, 102, 103, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 81, 132, 133, 41, 82, 83, 42, 14, + 51, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 43, 31, 32, + 33, 44, 85, 86, 154, 140, 141, 143, 144, 155, + 193, 87, 48, 156, 70, 170, 171, 50, 56, 72, + 57, 61, 67, 89, 90, 91, 74, 163, 93, 94, + 142, 92, 145, 97, 108, 109, 110, 111, 139, 112, + 113, 114, 115, 116, 153, 117, 118, 121, 119, 120, + 122, 180, 126, 127, 128, 135, 147, 186, 160, 161, + 124, 162, 164, 165, 166, 167, 168, 159, 173, 169, + 174, 172, 175, 176, 177, 178, 179, 181, 158, 182, + 183, 185, 190, 187, 189, 188, 191, 192, 195, 194, + 196, 0, 0, 198, 197, 73, 199, 49, 56, 58, +}; +short yycheck[] = { 89, + 90, 91, 305, 93, 269, 270, 257, 97, 98, 260, + 100, 262, 263, 316, 317, 318, 269, 270, 108, 269, + 110, 111, 270, 273, 114, 115, 116, 12, 13, 269, + 15, 256, 269, 18, 19, 20, 21, 270, 23, 269, + 270, 26, 27, 28, 29, 30, 269, 32, 33, 274, + 275, 269, 270, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 261, 269, 270, 270, 265, 266, 269, 294, + 270, 296, 297, 298, 299, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 269, 313, 314, + 315, 269, 258, 259, 259, 269, 270, 269, 270, 264, + 190, 267, 269, 268, 272, 269, 270, 269, 269, 272, + 270, 270, 270, 269, 269, 269, 273, 266, 269, 272, + 105, 273, 107, 269, 269, 272, 269, 269, 272, 270, + 270, 269, 269, 269, 273, 270, 270, 269, 271, 270, + 269, 271, 270, 270, 270, 270, 270, 173, 270, 270, + 273, 270, 270, 270, 270, 270, 270, 123, 269, 272, + 270, 273, 270, 270, 270, 270, 270, 269, 122, 270, + 273, 270, 269, 273, 270, 273, 271, 270, 270, 273, + 271, -1, -1, 271, 273, 269, 273, 270, 270, 270, +}; +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 319 +#if YYDEBUG +char *yyname[] = { +"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"A","B","C","E","F","I","L","N", +"P","R","S","T","SP","CRLF","COMMA","STRING","NUMBER","USER","PASS","ACCT", +"REIN","QUIT","PORT","PASV","TYPE","STRU","MODE","RETR","STOR","APPE","MLFL", +"MAIL","MSND","MSOM","MSAM","MRSQ","MRCP","ALLO","REST","RNFR","RNTO","ABOR", +"DELE","CWD","LIST","NLST","SITE","STAT","HELP","NOOP","MKD","RMD","PWD","CDUP", +"STOU","SMNT","SYST","SIZE","MDTM","UMASK","IDLE","CHMOD","LEXERR", +}; +char *yyrule[] = { +"$accept : cmd_list", +"cmd_list :", +"cmd_list : cmd_list cmd", +"cmd_list : cmd_list rcmd", +"cmd : USER SP username CRLF", +"cmd : PASS SP password CRLF", +"cmd : PORT SP host_port CRLF", +"cmd : PASV CRLF", +"cmd : TYPE SP type_code CRLF", +"cmd : STRU SP struct_code CRLF", +"cmd : MODE SP mode_code CRLF", +"cmd : ALLO SP NUMBER CRLF", +"cmd : ALLO SP NUMBER SP R SP NUMBER CRLF", +"cmd : RETR check_login SP pathname CRLF", +"cmd : STOR check_login SP pathname CRLF", +"cmd : APPE check_login SP pathname CRLF", +"cmd : NLST check_login CRLF", +"cmd : NLST check_login SP STRING CRLF", +"cmd : LIST check_login CRLF", +"cmd : LIST check_login SP pathname CRLF", +"cmd : STAT check_login SP pathname CRLF", +"cmd : STAT CRLF", +"cmd : DELE check_login SP pathname CRLF", +"cmd : RNTO SP pathname CRLF", +"cmd : ABOR CRLF", +"cmd : CWD check_login CRLF", +"cmd : CWD check_login SP pathname CRLF", +"cmd : HELP CRLF", +"cmd : HELP SP STRING CRLF", +"cmd : NOOP CRLF", +"cmd : MKD check_login SP pathname CRLF", +"cmd : RMD check_login SP pathname CRLF", +"cmd : PWD check_login CRLF", +"cmd : CDUP check_login CRLF", +"cmd : SITE SP HELP CRLF", +"cmd : SITE SP HELP SP STRING CRLF", +"cmd : SITE SP UMASK check_login CRLF", +"cmd : SITE SP UMASK check_login SP octal_number CRLF", +"cmd : SITE SP CHMOD check_login SP octal_number SP pathname CRLF", +"cmd : SITE SP IDLE CRLF", +"cmd : SITE SP IDLE SP NUMBER CRLF", +"cmd : STOU check_login SP pathname CRLF", +"cmd : SYST CRLF", +"cmd : SIZE check_login SP pathname CRLF", +"cmd : MDTM check_login SP pathname CRLF", +"cmd : QUIT CRLF", +"cmd : error CRLF", +"rcmd : RNFR check_login SP pathname CRLF", +"username : STRING", +"password :", +"password : STRING", +"byte_size : NUMBER", +"host_port : NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER", +"form_code : N", +"form_code : T", +"form_code : C", +"type_code : A", +"type_code : A SP form_code", +"type_code : E", +"type_code : E SP form_code", +"type_code : I", +"type_code : L", +"type_code : L SP byte_size", +"type_code : L byte_size", +"struct_code : F", +"struct_code : R", +"struct_code : P", +"mode_code : S", +"mode_code : B", +"mode_code : C", +"pathname : pathstring", +"pathstring : STRING", +"octal_number : NUMBER", +"check_login :", +}; +#endif +#ifndef YYSTYPE +typedef int YYSTYPE; +#endif +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 500 +#define YYMAXDEPTH 500 +#endif +#endif +int yydebug; +int yynerrs; +int yyerrflag; +int yychar; +short *yyssp; +YYSTYPE *yyvsp; +YYSTYPE yyval; +YYSTYPE yylval; +short yyss[YYSTACKSIZE]; +YYSTYPE yyvs[YYSTACKSIZE]; +#define yystacksize YYSTACKSIZE +#line 658 "ftp.y" + +extern jmp_buf errcatch; + +#define CMD 0 /* beginning of command */ +#define ARGS 1 /* expect miscellaneous arguments */ +#define STR1 2 /* expect SP followed by STRING */ +#define STR2 3 /* expect STRING */ +#define OSTR 4 /* optional SP then STRING */ +#define ZSTR1 5 /* SP then optional STRING */ +#define ZSTR2 6 /* optional STRING after SP */ +#define SITECMD 7 /* SITE command */ +#define NSTR 8 /* Number followed by a string */ + +struct tab { + char *name; + short token; + short state; + short implemented; /* 1 if command is implemented */ + char *help; +}; + +struct tab cmdtab[] = { /* In order defined in RFC 765 */ + { "USER", USER, STR1, 1, " username" }, + { "PASS", PASS, ZSTR1, 1, " password" }, + { "ACCT", ACCT, STR1, 0, "(specify account)" }, + { "SMNT", SMNT, ARGS, 0, "(structure mount)" }, + { "REIN", REIN, ARGS, 0, "(reinitialize server state)" }, + { "QUIT", QUIT, ARGS, 1, "(terminate service)", }, + { "PORT", PORT, ARGS, 1, " b0, b1, b2, b3, b4" }, + { "PASV", PASV, ARGS, 1, "(set server in passive mode)" }, + { "TYPE", TYPE, ARGS, 1, " [ A | E | I | L ]" }, + { "STRU", STRU, ARGS, 1, "(specify file structure)" }, + { "MODE", MODE, ARGS, 1, "(specify transfer mode)" }, + { "RETR", RETR, STR1, 1, " file-name" }, + { "STOR", STOR, STR1, 1, " file-name" }, + { "APPE", APPE, STR1, 1, " file-name" }, + { "MLFL", MLFL, OSTR, 0, "(mail file)" }, + { "MAIL", MAIL, OSTR, 0, "(mail to user)" }, + { "MSND", MSND, OSTR, 0, "(mail send to terminal)" }, + { "MSOM", MSOM, OSTR, 0, "(mail send to terminal or mailbox)" }, + { "MSAM", MSAM, OSTR, 0, "(mail send to terminal and mailbox)" }, + { "MRSQ", MRSQ, OSTR, 0, "(mail recipient scheme question)" }, + { "MRCP", MRCP, STR1, 0, "(mail recipient)" }, + { "ALLO", ALLO, ARGS, 1, "allocate storage (vacuously)" }, + { "REST", REST, ARGS, 0, "(restart command)" }, + { "RNFR", RNFR, STR1, 1, " file-name" }, + { "RNTO", RNTO, STR1, 1, " file-name" }, + { "ABOR", ABOR, ARGS, 1, "(abort operation)" }, + { "DELE", DELE, STR1, 1, " file-name" }, + { "CWD", CWD, OSTR, 1, "[ directory-name ]" }, + { "XCWD", CWD, OSTR, 1, "[ directory-name ]" }, + { "LIST", LIST, OSTR, 1, "[ path-name ]" }, + { "NLST", NLST, OSTR, 1, "[ path-name ]" }, + { "SITE", SITE, SITECMD, 1, "site-cmd [ arguments ]" }, + { "SYST", SYST, ARGS, 1, "(get type of operating system)" }, + { "STAT", STAT, OSTR, 1, "[ path-name ]" }, + { "HELP", HELP, OSTR, 1, "[ ]" }, + { "NOOP", NOOP, ARGS, 1, "" }, + { "MKD", MKD, STR1, 1, " path-name" }, + { "XMKD", MKD, STR1, 1, " path-name" }, + { "RMD", RMD, STR1, 1, " path-name" }, + { "XRMD", RMD, STR1, 1, " path-name" }, + { "PWD", PWD, ARGS, 1, "(return current directory)" }, + { "XPWD", PWD, ARGS, 1, "(return current directory)" }, + { "CDUP", CDUP, ARGS, 1, "(change to parent directory)" }, + { "XCUP", CDUP, ARGS, 1, "(change to parent directory)" }, + { "STOU", STOU, STR1, 1, " file-name" }, + { "SIZE", SIZE, OSTR, 1, " path-name" }, + { "MDTM", MDTM, OSTR, 1, " path-name" }, + { NULL, 0, 0, 0, 0 } +}; + +struct tab sitetab[] = { + { "UMASK", UMASK, ARGS, 1, "[ umask ]" }, + { "IDLE", IDLE, ARGS, 1, "[ maximum-idle-time ]" }, + { "CHMOD", CHMOD, NSTR, 1, " mode file-name" }, + { "HELP", HELP, OSTR, 1, "[ ]" }, + { NULL, 0, 0, 0, 0 } +}; + +struct tab * +lookup(p, cmd) + register struct tab *p; + char *cmd; +{ + + for (; p->name != NULL; p++) + if (strcmp(cmd, p->name) == 0) + return (p); + return (0); +} + +#include + +/* + * getline - a hacked up version of fgets to ignore TELNET escape codes. + */ +char * +getline(s, n, iop) + char *s; + register FILE *iop; +{ + register c; + register char *cs; + + cs = s; +/* tmpline may contain saved command from urgent mode interruption */ + for (c = 0; tmpline[c] != '\0' && --n > 0; ++c) { + *cs++ = tmpline[c]; + if (tmpline[c] == '\n') { + *cs++ = '\0'; + if (debug) + syslog(LOG_DEBUG, "command: %s", s); + tmpline[0] = '\0'; + return(s); + } + if (c == 0) + tmpline[0] = '\0'; + } + while ((c = getc(iop)) != EOF) { + c &= 0377; + if (c == IAC) { + if ((c = getc(iop)) != EOF) { + c &= 0377; + switch (c) { + case WILL: + case WONT: + c = getc(iop); + printf("%c%c%c", IAC, DONT, 0377&c); + (void) fflush(stdout); + continue; + case DO: + case DONT: + c = getc(iop); + printf("%c%c%c", IAC, WONT, 0377&c); + (void) fflush(stdout); + continue; + case IAC: + break; + default: + continue; /* ignore command */ + } + } + } + *cs++ = c; + if (--n <= 0 || c == '\n') + break; + } + if (c == EOF && cs == s) + return (NULL); + *cs++ = '\0'; + if (debug) + syslog(LOG_DEBUG, "command: %s", s); + return (s); +} + +static int +toolong() +{ + time_t now; + extern char *ctime(); + extern time_t time(); + + reply(421, + "Timeout (%d seconds): closing control connection.", timeout); + (void) time(&now); + if (logging) { + syslog(LOG_INFO, + "User %s timed out after %d seconds at %s", + (pw ? pw -> pw_name : "unknown"), timeout, ctime(&now)); + } + dologout(1); +} + +yylex() +{ + static int cpos, state; + register char *cp, *cp2; + register struct tab *p; + int n; + char c, *strpbrk(); + char *copy(); + + for (;;) { + switch (state) { + + case CMD: + (void) signal(SIGALRM, toolong); + (void) alarm((unsigned) timeout); + if (getline(cbuf, sizeof(cbuf)-1, stdin) == NULL) { + reply(221, "You could at least say goodbye."); + dologout(0); + } + (void) alarm(0); +#ifdef SETPROCTITLE + if (strncasecmp(cbuf, "PASS", 4) != NULL) + setproctitle("%s: %s", proctitle, cbuf); +#endif /* SETPROCTITLE */ + if ((cp = index(cbuf, '\r'))) { + *cp++ = '\n'; + *cp = '\0'; + } + if ((cp = strpbrk(cbuf, " \n"))) + cpos = cp - cbuf; + if (cpos == 0) + cpos = 4; + c = cbuf[cpos]; + cbuf[cpos] = '\0'; + upper(cbuf); + p = lookup(cmdtab, cbuf); + cbuf[cpos] = c; + if (p != 0) { + if (p->implemented == 0) { + nack(p->name); + longjmp(errcatch,0); + /* NOTREACHED */ + } + state = p->state; + *(char **)&yylval = p->name; + return (p->token); + } + break; + + case SITECMD: + if (cbuf[cpos] == ' ') { + cpos++; + return (SP); + } + cp = &cbuf[cpos]; + if ((cp2 = strpbrk(cp, " \n"))) + cpos = cp2 - cbuf; + c = cbuf[cpos]; + cbuf[cpos] = '\0'; + upper(cp); + p = lookup(sitetab, cp); + cbuf[cpos] = c; + if (p != 0) { + if (p->implemented == 0) { + state = CMD; + nack(p->name); + longjmp(errcatch,0); + /* NOTREACHED */ + } + state = p->state; + *(char **)&yylval = p->name; + return (p->token); + } + state = CMD; + break; + + case OSTR: + if (cbuf[cpos] == '\n') { + state = CMD; + return (CRLF); + } + /* FALLTHROUGH */ + + case STR1: + case ZSTR1: + dostr1: + if (cbuf[cpos] == ' ') { + cpos++; + state = state == OSTR ? STR2 : ++state; + return (SP); + } + break; + + case ZSTR2: + if (cbuf[cpos] == '\n') { + state = CMD; + return (CRLF); + } + /* FALLTHROUGH */ + + case STR2: + cp = &cbuf[cpos]; + n = strlen(cp); + cpos += n - 1; + /* + * Make sure the string is nonempty and \n terminated. + */ + if (n > 1 && cbuf[cpos] == '\n') { + cbuf[cpos] = '\0'; + *(char **)&yylval = copy(cp); + cbuf[cpos] = '\n'; + state = ARGS; + return (STRING); + } + break; + + case NSTR: + if (cbuf[cpos] == ' ') { + cpos++; + return (SP); + } + if (isdigit(cbuf[cpos])) { + cp = &cbuf[cpos]; + while (isdigit(cbuf[++cpos])) + ; + c = cbuf[cpos]; + cbuf[cpos] = '\0'; + yylval = atoi(cp); + cbuf[cpos] = c; + state = STR1; + return (NUMBER); + } + state = STR1; + goto dostr1; + + case ARGS: + if (isdigit(cbuf[cpos])) { + cp = &cbuf[cpos]; + while (isdigit(cbuf[++cpos])) + ; + c = cbuf[cpos]; + cbuf[cpos] = '\0'; + yylval = atoi(cp); + cbuf[cpos] = c; + return (NUMBER); + } + switch (cbuf[cpos++]) { + + case '\n': + state = CMD; + return (CRLF); + + case ' ': + return (SP); + + case ',': + return (COMMA); + + case 'A': + case 'a': + return (A); + + case 'B': + case 'b': + return (B); + + case 'C': + case 'c': + return (C); + + case 'E': + case 'e': + return (E); + + case 'F': + case 'f': + return (F); + + case 'I': + case 'i': + return (I); + + case 'L': + case 'l': + return (L); + + case 'N': + case 'n': + return (N); + + case 'P': + case 'p': + return (P); + + case 'R': + case 'r': + return (R); + + case 'S': + case 's': + return (S); + + case 'T': + case 't': + return (T); + + } + break; + + default: + fatal("Unknown state in scanner."); + } + yyerror((char *) 0); + state = CMD; + longjmp(errcatch,0); + } +} + +upper(s) + register char *s; +{ + while (*s != '\0') { + if (islower(*s)) + *s = toupper(*s); + s++; + } +} + +char * +copy(s) + char *s; +{ + char *p; + extern char *malloc(), *strcpy(); + + p = malloc((unsigned) strlen(s) + 1); + if (p == NULL) + fatal("Ran out of memory."); + (void) strcpy(p, s); + return (p); +} + +help(ctab, s) + struct tab *ctab; + char *s; +{ + register struct tab *c; + register int width, NCMDS; + char *type; + + if (ctab == sitetab) + type = "SITE "; + else + type = ""; + width = 0, NCMDS = 0; + for (c = ctab; c->name != NULL; c++) { + int len = strlen(c->name); + + if (len > width) + width = len; + NCMDS++; + } + width = (width + 8) &~ 7; + if (s == 0) { + register int i, j, w; + int columns, lines; + + lreply(214, "The following %scommands are recognized %s.", + type, "(* =>'s unimplemented)"); + columns = 76 / width; + if (columns == 0) + columns = 1; + lines = (NCMDS + columns - 1) / columns; + for (i = 0; i < lines; i++) { + printf(" "); + for (j = 0; j < columns; j++) { + c = ctab + j * lines + i; + printf("%s%c", c->name, + c->implemented ? ' ' : '*'); + if (c + lines >= &ctab[NCMDS]) + break; + w = strlen(c->name) + 1; + while (w < width) { + putchar(' '); + w++; + } + } + printf("\r\n"); + } + (void) fflush(stdout); + reply(214, "Direct comments to ftp-bugs@%s.", hostname); + return; + } + upper(s); + c = lookup(ctab, s); + if (c == (struct tab *)0) { + reply(502, "Unknown command %s.", s); + return; + } + if (c->implemented) + reply(214, "Syntax: %s%s %s", type, c->name, c->help); + else + reply(214, "%s%-*s\t%s; unimplemented.", type, width, + c->name, c->help); +} + +sizecmd(filename) +char *filename; +{ + switch (type) { + case TYPE_L: + case TYPE_I: { + struct stat stbuf; + if (stat(filename, &stbuf) < 0 || + (stbuf.st_mode&S_IFMT) != S_IFREG) + reply(550, "%s: not a plain file.", filename); + else + reply(213, "%llu", (long long)stbuf.st_size); + break;} + case TYPE_A: { + FILE *fin; + register int c, count; + struct stat stbuf; + fin = fopen(filename, "r"); + if (fin == NULL) { + perror_reply(550, filename); + return; + } + if (fstat(fileno(fin), &stbuf) < 0 || + (stbuf.st_mode&S_IFMT) != S_IFREG) { + reply(550, "%s: not a plain file.", filename); + (void) fclose(fin); + return; + } + + count = 0; + while((c=getc(fin)) != EOF) { + if (c == '\n') /* will get expanded to \r\n */ + count++; + count++; + } + (void) fclose(fin); + + reply(213, "%ld", count); + break;} + default: + reply(504, "SIZE not implemented for Type %c.", "?AEIL"[type]); + } +} +#line 908 "ftp.tab.c" +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +int +yyparse() +{ + register int yym, yyn, yystate; +#if YYDEBUG + register char *yys; + extern char *getenv(); + + if (yys = getenv("YYDEBUG")) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } +#endif + + yynerrs = 0; + yyerrflag = 0; + yychar = (-1); + + yyssp = yyss; + yyvsp = yyvs; + *yyssp = yystate = 0; + +yyloop: + if (yyn = yydefred[yystate]) goto yyreduce; + if (yychar < 0) + { + if ((yychar = yylex()) < 0) yychar = 0; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yyssp >= yyss + yystacksize - 1) + { + goto yyoverflow; + } + *++yyssp = yystate = yytable[yyn]; + *++yyvsp = yylval; + yychar = (-1); + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag) goto yyinrecovery; +#ifdef lint + goto yynewerror; +#endif +yynewerror: + yyerror("syntax error"); +#ifdef lint + goto yyerrlab; +#endif +yyerrlab: + ++yynerrs; +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yyssp, yytable[yyn]); +#endif + if (yyssp >= yyss + yystacksize - 1) + { + goto yyoverflow; + } + *++yyssp = yystate = yytable[yyn]; + *++yyvsp = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yyssp); +#endif + if (yyssp <= yyss) goto yyabort; + --yyssp; + --yyvsp; + } + } + } + else + { + if (yychar == 0) goto yyabort; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = (-1); + goto yyloop; + } +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + yyval = yyvsp[1-yym]; + switch (yyn) + { +case 2: +#line 99 "ftp.y" + { + fromname = (char *) 0; + } +break; +case 4: +#line 106 "ftp.y" + { + user((char *) yyvsp[-1]); + free((char *) yyvsp[-1]); + } +break; +case 5: +#line 111 "ftp.y" + { + pass((char *) yyvsp[-1]); + free((char *) yyvsp[-1]); + } +break; +case 6: +#line 116 "ftp.y" + { + usedefault = 0; + if (pdata >= 0) { + (void) close(pdata); + pdata = -1; + } + reply(200, "PORT command successful."); + } +break; +case 7: +#line 125 "ftp.y" + { + passive(); + } +break; +case 8: +#line 129 "ftp.y" + { + switch (cmd_type) { + + case TYPE_A: + if (cmd_form == FORM_N) { + reply(200, "Type set to A."); + type = cmd_type; + form = cmd_form; + } else + reply(504, "Form must be N."); + break; + + case TYPE_E: + reply(504, "Type E not implemented."); + break; + + case TYPE_I: + reply(200, "Type set to I."); + type = cmd_type; + break; + + case TYPE_L: +#if NBBY == 8 + if (cmd_bytesz == 8) { + reply(200, + "Type set to L (byte size 8)."); + type = cmd_type; + } else + reply(504, "Byte size must be 8."); +#else /* NBBY == 8 */ + UNIMPLEMENTED for NBBY != 8 +#endif /* NBBY == 8 */ + } + } +break; +case 9: +#line 164 "ftp.y" + { + switch (yyvsp[-1]) { + + case STRU_F: + reply(200, "STRU F ok."); + break; + + default: + reply(504, "Unimplemented STRU type."); + } + } +break; +case 10: +#line 176 "ftp.y" + { + switch (yyvsp[-1]) { + + case MODE_S: + reply(200, "MODE S ok."); + break; + + default: + reply(502, "Unimplemented MODE type."); + } + } +break; +case 11: +#line 188 "ftp.y" + { + reply(202, "ALLO command ignored."); + } +break; +case 12: +#line 192 "ftp.y" + { + reply(202, "ALLO command ignored."); + } +break; +case 13: +#line 196 "ftp.y" + { + if (yyvsp[-3] && yyvsp[-1] != NULL) + retrieve((char *) 0, (char *) yyvsp[-1]); + if (yyvsp[-1] != NULL) + free((char *) yyvsp[-1]); + } +break; +case 14: +#line 203 "ftp.y" + { + if (yyvsp[-3] && yyvsp[-1] != NULL) + store((char *) yyvsp[-1], "w", 0); + if (yyvsp[-1] != NULL) + free((char *) yyvsp[-1]); + } +break; +case 15: +#line 210 "ftp.y" + { + if (yyvsp[-3] && yyvsp[-1] != NULL) + store((char *) yyvsp[-1], "a", 0); + if (yyvsp[-1] != NULL) + free((char *) yyvsp[-1]); + } +break; +case 16: +#line 217 "ftp.y" + { + if (yyvsp[-1]) + send_file_list("."); + } +break; +case 17: +#line 222 "ftp.y" + { + if (yyvsp[-3] && yyvsp[-1] != NULL) + send_file_list((char *) yyvsp[-1]); + if (yyvsp[-1] != NULL) + free((char *) yyvsp[-1]); + } +break; +case 18: +#line 229 "ftp.y" + { + if (yyvsp[-1]) + retrieve("/bin/ls -lgA", ""); + } +break; +case 19: +#line 234 "ftp.y" + { + if (yyvsp[-3] && yyvsp[-1] != NULL) + retrieve("/bin/ls -lgA %s", (char *) yyvsp[-1]); + if (yyvsp[-1] != NULL) + free((char *) yyvsp[-1]); + } +break; +case 20: +#line 241 "ftp.y" + { + if (yyvsp[-3] && yyvsp[-1] != NULL) + statfilecmd((char *) yyvsp[-1]); + if (yyvsp[-1] != NULL) + free((char *) yyvsp[-1]); + } +break; +case 21: +#line 248 "ftp.y" + { + statcmd(); + } +break; +case 22: +#line 252 "ftp.y" + { + if (yyvsp[-3] && yyvsp[-1] != NULL) + delete((char *) yyvsp[-1]); + if (yyvsp[-1] != NULL) + free((char *) yyvsp[-1]); + } +break; +case 23: +#line 259 "ftp.y" + { + if (fromname) { + renamecmd(fromname, (char *) yyvsp[-1]); + free(fromname); + fromname = (char *) 0; + } else { + reply(503, "Bad sequence of commands."); + } + free((char *) yyvsp[-1]); + } +break; +case 24: +#line 270 "ftp.y" + { + reply(225, "ABOR command successful."); + } +break; +case 25: +#line 274 "ftp.y" + { + if (yyvsp[-1]) + cwd(pw->pw_dir); + } +break; +case 26: +#line 279 "ftp.y" + { + if (yyvsp[-3] && yyvsp[-1] != NULL) + cwd((char *) yyvsp[-1]); + if (yyvsp[-1] != NULL) + free((char *) yyvsp[-1]); + } +break; +case 27: +#line 286 "ftp.y" + { + help(cmdtab, (char *) 0); + } +break; +case 28: +#line 290 "ftp.y" + { + register char *cp = (char *)yyvsp[-1]; + + if (strncasecmp(cp, "SITE", 4) == 0) { + cp = (char *)yyvsp[-1] + 4; + if (*cp == ' ') + cp++; + if (*cp) + help(sitetab, cp); + else + help(sitetab, (char *) 0); + } else + help(cmdtab, (char *) yyvsp[-1]); + } +break; +case 29: +#line 305 "ftp.y" + { + reply(200, "NOOP command successful."); + } +break; +case 30: +#line 309 "ftp.y" + { + if (yyvsp[-3] && yyvsp[-1] != NULL) + makedir((char *) yyvsp[-1]); + if (yyvsp[-1] != NULL) + free((char *) yyvsp[-1]); + } +break; +case 31: +#line 316 "ftp.y" + { + if (yyvsp[-3] && yyvsp[-1] != NULL) + removedir((char *) yyvsp[-1]); + if (yyvsp[-1] != NULL) + free((char *) yyvsp[-1]); + } +break; +case 32: +#line 323 "ftp.y" + { + if (yyvsp[-1]) + pwd(); + } +break; +case 33: +#line 328 "ftp.y" + { + if (yyvsp[-1]) + cwd(".."); + } +break; +case 34: +#line 333 "ftp.y" + { + help(sitetab, (char *) 0); + } +break; +case 35: +#line 337 "ftp.y" + { + help(sitetab, (char *) yyvsp[-1]); + } +break; +case 36: +#line 341 "ftp.y" + { + int oldmask; + + if (yyvsp[-1]) { + oldmask = umask(0); + (void) umask(oldmask); + reply(200, "Current UMASK is %03o", oldmask); + } + } +break; +case 37: +#line 351 "ftp.y" + { + int oldmask; + + if (yyvsp[-3]) { + if ((yyvsp[-1] == -1) || (yyvsp[-1] > 0777)) { + reply(501, "Bad UMASK value"); + } else { + oldmask = umask(yyvsp[-1]); + reply(200, + "UMASK set to %03o (was %03o)", + yyvsp[-1], oldmask); + } + } + } +break; +case 38: +#line 366 "ftp.y" + { + if (yyvsp[-5] && (yyvsp[-1] != NULL)) { + if (yyvsp[-3] > 0777) + reply(501, + "CHMOD: Mode value must be between 0 and 0777"); + else if (chmod((char *) yyvsp[-1], yyvsp[-3]) < 0) + perror_reply(550, (char *) yyvsp[-1]); + else + reply(200, "CHMOD command successful."); + } + if (yyvsp[-1] != NULL) + free((char *) yyvsp[-1]); + } +break; +case 39: +#line 380 "ftp.y" + { + reply(200, + "Current IDLE time limit is %d seconds; max %d", + timeout, maxtimeout); + } +break; +case 40: +#line 386 "ftp.y" + { + if (yyvsp[-1] < 30 || yyvsp[-1] > maxtimeout) { + reply(501, + "Maximum IDLE time must be between 30 and %d seconds", + maxtimeout); + } else { + timeout = yyvsp[-1]; + (void) alarm((unsigned) timeout); + reply(200, + "Maximum IDLE time set to %d seconds", + timeout); + } + } +break; +case 41: +#line 400 "ftp.y" + { + if (yyvsp[-3] && yyvsp[-1] != NULL) + store((char *) yyvsp[-1], "w", 1); + if (yyvsp[-1] != NULL) + free((char *) yyvsp[-1]); + } +break; +case 42: +#line 407 "ftp.y" + { +#ifdef unix +#ifdef BSD + reply(215, "UNIX Type: L%d Version: BSD-%d", + NBBY, BSD); +#else /* BSD */ + reply(215, "UNIX Type: L%d", NBBY); +#endif /* BSD */ +#else /* unix */ + reply(215, "UNKNOWN Type: L%d", NBBY); +#endif /* unix */ + } +break; +case 43: +#line 428 "ftp.y" + { + if (yyvsp[-3] && yyvsp[-1] != NULL) + sizecmd((char *) yyvsp[-1]); + if (yyvsp[-1] != NULL) + free((char *) yyvsp[-1]); + } +break; +case 44: +#line 445 "ftp.y" + { + if (yyvsp[-3] && yyvsp[-1] != NULL) { + struct stat stbuf; + if (stat((char *) yyvsp[-1], &stbuf) < 0) + perror_reply(550, "%s", (char *) yyvsp[-1]); + else if ((stbuf.st_mode&S_IFMT) != S_IFREG) { + reply(550, "%s: not a plain file.", + (char *) yyvsp[-1]); + } else { + register struct tm *t; + struct tm *gmtime(); + t = gmtime(&stbuf.st_mtime); + reply(213, + "%04d%02d%02d%02d%02d%02d", + 1900 + t->tm_year, + t->tm_mon+1, t->tm_mday, + t->tm_hour, t->tm_min, t->tm_sec); + } + } + if (yyvsp[-1] != NULL) + free((char *) yyvsp[-1]); + } +break; +case 45: +#line 467 "ftp.y" + { + reply(221, "Goodbye."); + dologout(0); + } +break; +case 46: +#line 472 "ftp.y" + { + yyerrok; + } +break; +case 47: +#line 477 "ftp.y" + { + char *renamefrom(); + + if (yyvsp[-3] && yyvsp[-1]) { + fromname = renamefrom((char *) yyvsp[-1]); + if (fromname == (char *) 0 && yyvsp[-1]) { + free((char *) yyvsp[-1]); + } + } + } +break; +case 49: +#line 493 "ftp.y" + { + *(char **)&(yyval) = ""; + } +break; +case 52: +#line 504 "ftp.y" + { + register char *a, *p; + + a = (char *)&data_dest.sin_addr; + a[0] = yyvsp[-10]; a[1] = yyvsp[-8]; a[2] = yyvsp[-6]; a[3] = yyvsp[-4]; + p = (char *)&data_dest.sin_port; + p[0] = yyvsp[-2]; p[1] = yyvsp[0]; + data_dest.sin_family = AF_INET; + } +break; +case 53: +#line 516 "ftp.y" + { + yyval = FORM_N; + } +break; +case 54: +#line 520 "ftp.y" + { + yyval = FORM_T; + } +break; +case 55: +#line 524 "ftp.y" + { + yyval = FORM_C; + } +break; +case 56: +#line 530 "ftp.y" + { + cmd_type = TYPE_A; + cmd_form = FORM_N; + } +break; +case 57: +#line 535 "ftp.y" + { + cmd_type = TYPE_A; + cmd_form = yyvsp[0]; + } +break; +case 58: +#line 540 "ftp.y" + { + cmd_type = TYPE_E; + cmd_form = FORM_N; + } +break; +case 59: +#line 545 "ftp.y" + { + cmd_type = TYPE_E; + cmd_form = yyvsp[0]; + } +break; +case 60: +#line 550 "ftp.y" + { + cmd_type = TYPE_I; + } +break; +case 61: +#line 554 "ftp.y" + { + cmd_type = TYPE_L; + cmd_bytesz = NBBY; + } +break; +case 62: +#line 559 "ftp.y" + { + cmd_type = TYPE_L; + cmd_bytesz = yyvsp[0]; + } +break; +case 63: +#line 565 "ftp.y" + { + cmd_type = TYPE_L; + cmd_bytesz = yyvsp[0]; + } +break; +case 64: +#line 572 "ftp.y" + { + yyval = STRU_F; + } +break; +case 65: +#line 576 "ftp.y" + { + yyval = STRU_R; + } +break; +case 66: +#line 580 "ftp.y" + { + yyval = STRU_P; + } +break; +case 67: +#line 586 "ftp.y" + { + yyval = MODE_S; + } +break; +case 68: +#line 590 "ftp.y" + { + yyval = MODE_B; + } +break; +case 69: +#line 594 "ftp.y" + { + yyval = MODE_C; + } +break; +case 70: +#line 600 "ftp.y" + { + /* + * Problem: this production is used for all pathname + * processing, but only gives a 550 error reply. + * This is a valid reply in some cases but not in others. + */ + if (logged_in && yyvsp[0] && strncmp((char *) yyvsp[0], "~", 1) == 0) { + *(char **)&(yyval) = *glob((char *) yyvsp[0]); + if (globerr != NULL) { + reply(550, globerr); + yyval = NULL; + } + free((char *) yyvsp[0]); + } else + yyval = yyvsp[0]; + } +break; +case 72: +#line 622 "ftp.y" + { + register int ret, dec, multby, digit; + + /* + * Convert a number that was read as decimal number + * to what it would be if it had been read as octal. + */ + dec = yyvsp[0]; + multby = 1; + ret = 0; + while (dec) { + digit = dec%10; + if (digit > 7) { + ret = -1; + break; + } + ret += digit * multby; + multby *= 8; + dec /= 10; + } + yyval = ret; + } +break; +case 73: +#line 647 "ftp.y" + { + if (logged_in) + yyval = 1; + else { + reply(530, "Please login with USER and PASS."); + yyval = 0; + } + } +break; +#line 1688 "ftp.tab.c" + } + yyssp -= yym; + yystate = *yyssp; + yyvsp -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yyssp = YYFINAL; + *++yyvsp = yyval; + if (yychar < 0) + { + if ((yychar = yylex()) < 0) yychar = 0; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == 0) goto yyaccept; + goto yyloop; + } + if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yyssp, yystate); +#endif + if (yyssp >= yyss + yystacksize - 1) + { + goto yyoverflow; + } + *++yyssp = yystate; + *++yyvsp = yyval; + goto yyloop; +yyoverflow: + yyerror("yacc stack overflow"); +yyabort: + return (1); +yyaccept: + return (0); +} diff --git a/commands/yacc/test/ftp.tab.h b/commands/yacc/test/ftp.tab.h new file mode 100644 index 000000000..e6f660166 --- /dev/null +++ b/commands/yacc/test/ftp.tab.h @@ -0,0 +1,65 @@ +/* $NetBSD: ftp.tab.h,v 1.2 1998/01/09 08:08:56 perry Exp $ */ + +#define A 257 +#define B 258 +#define C 259 +#define E 260 +#define F 261 +#define I 262 +#define L 263 +#define N 264 +#define P 265 +#define R 266 +#define S 267 +#define T 268 +#define SP 269 +#define CRLF 270 +#define COMMA 271 +#define STRING 272 +#define NUMBER 273 +#define USER 274 +#define PASS 275 +#define ACCT 276 +#define REIN 277 +#define QUIT 278 +#define PORT 279 +#define PASV 280 +#define TYPE 281 +#define STRU 282 +#define MODE 283 +#define RETR 284 +#define STOR 285 +#define APPE 286 +#define MLFL 287 +#define MAIL 288 +#define MSND 289 +#define MSOM 290 +#define MSAM 291 +#define MRSQ 292 +#define MRCP 293 +#define ALLO 294 +#define REST 295 +#define RNFR 296 +#define RNTO 297 +#define ABOR 298 +#define DELE 299 +#define CWD 300 +#define LIST 301 +#define NLST 302 +#define SITE 303 +#define STAT 304 +#define HELP 305 +#define NOOP 306 +#define MKD 307 +#define RMD 308 +#define PWD 309 +#define CDUP 310 +#define STOU 311 +#define SMNT 312 +#define SYST 313 +#define SIZE 314 +#define MDTM 315 +#define UMASK 316 +#define IDLE 317 +#define CHMOD 318 +#define LEXERR 319 diff --git a/commands/yacc/test/ftp.y b/commands/yacc/test/ftp.y new file mode 100644 index 000000000..a723f91b4 --- /dev/null +++ b/commands/yacc/test/ftp.y @@ -0,0 +1,1185 @@ +/* $NetBSD: ftp.y,v 1.6 2001/01/04 23:05:57 lukem Exp $ */ + +/* + * Copyright (c) 1985, 1988 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * from: @(#)ftpcmd.y 5.20.1.1 (Berkeley) 3/2/89 + * $NetBSD: ftp.y,v 1.6 2001/01/04 23:05:57 lukem Exp $ + */ + +/* + * Grammar for FTP commands. + * See RFC 959. + */ + +%{ + +#ifndef lint +/*static char sccsid[] = "from: @(#)ftpcmd.y 5.20.1.1 (Berkeley) 3/2/89";*/ +static char rcsid[] = "$NetBSD: ftp.y,v 1.6 2001/01/04 23:05:57 lukem Exp $"; +#endif /* not lint */ + +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +extern struct sockaddr_in data_dest; +extern int logged_in; +extern struct passwd *pw; +extern int guest; +extern int logging; +extern int type; +extern int form; +extern int debug; +extern int timeout; +extern int maxtimeout; +extern int pdata; +extern char hostname[], remotehost[]; +extern char proctitle[]; +extern char *globerr; +extern int usedefault; +extern int transflag; +extern char tmpline[]; +char **glob(); + +static int cmd_type; +static int cmd_form; +static int cmd_bytesz; +char cbuf[512]; +char *fromname; + +char *index(); +%} + +%token + A B C E F I + L N P R S T + + SP CRLF COMMA STRING NUMBER + + USER PASS ACCT REIN QUIT PORT + PASV TYPE STRU MODE RETR STOR + APPE MLFL MAIL MSND MSOM MSAM + MRSQ MRCP ALLO REST RNFR RNTO + ABOR DELE CWD LIST NLST SITE + STAT HELP NOOP MKD RMD PWD + CDUP STOU SMNT SYST SIZE MDTM + + UMASK IDLE CHMOD + + LEXERR + +%start cmd_list + +%% + +cmd_list: /* empty */ + | cmd_list cmd + = { + fromname = (char *) 0; + } + | cmd_list rcmd + ; + +cmd: USER SP username CRLF + = { + user((char *) $3); + free((char *) $3); + } + | PASS SP password CRLF + = { + pass((char *) $3); + free((char *) $3); + } + | PORT SP host_port CRLF + = { + usedefault = 0; + if (pdata >= 0) { + (void) close(pdata); + pdata = -1; + } + reply(200, "PORT command successful."); + } + | PASV CRLF + = { + passive(); + } + | TYPE SP type_code CRLF + = { + switch (cmd_type) { + + case TYPE_A: + if (cmd_form == FORM_N) { + reply(200, "Type set to A."); + type = cmd_type; + form = cmd_form; + } else + reply(504, "Form must be N."); + break; + + case TYPE_E: + reply(504, "Type E not implemented."); + break; + + case TYPE_I: + reply(200, "Type set to I."); + type = cmd_type; + break; + + case TYPE_L: +#if NBBY == 8 + if (cmd_bytesz == 8) { + reply(200, + "Type set to L (byte size 8)."); + type = cmd_type; + } else + reply(504, "Byte size must be 8."); +#else /* NBBY == 8 */ + UNIMPLEMENTED for NBBY != 8 +#endif /* NBBY == 8 */ + } + } + | STRU SP struct_code CRLF + = { + switch ($3) { + + case STRU_F: + reply(200, "STRU F ok."); + break; + + default: + reply(504, "Unimplemented STRU type."); + } + } + | MODE SP mode_code CRLF + = { + switch ($3) { + + case MODE_S: + reply(200, "MODE S ok."); + break; + + default: + reply(502, "Unimplemented MODE type."); + } + } + | ALLO SP NUMBER CRLF + = { + reply(202, "ALLO command ignored."); + } + | ALLO SP NUMBER SP R SP NUMBER CRLF + = { + reply(202, "ALLO command ignored."); + } + | RETR check_login SP pathname CRLF + = { + if ($2 && $4 != NULL) + retrieve((char *) 0, (char *) $4); + if ($4 != NULL) + free((char *) $4); + } + | STOR check_login SP pathname CRLF + = { + if ($2 && $4 != NULL) + store((char *) $4, "w", 0); + if ($4 != NULL) + free((char *) $4); + } + | APPE check_login SP pathname CRLF + = { + if ($2 && $4 != NULL) + store((char *) $4, "a", 0); + if ($4 != NULL) + free((char *) $4); + } + | NLST check_login CRLF + = { + if ($2) + send_file_list("."); + } + | NLST check_login SP STRING CRLF + = { + if ($2 && $4 != NULL) + send_file_list((char *) $4); + if ($4 != NULL) + free((char *) $4); + } + | LIST check_login CRLF + = { + if ($2) + retrieve("/bin/ls -lgA", ""); + } + | LIST check_login SP pathname CRLF + = { + if ($2 && $4 != NULL) + retrieve("/bin/ls -lgA %s", (char *) $4); + if ($4 != NULL) + free((char *) $4); + } + | STAT check_login SP pathname CRLF + = { + if ($2 && $4 != NULL) + statfilecmd((char *) $4); + if ($4 != NULL) + free((char *) $4); + } + | STAT CRLF + = { + statcmd(); + } + | DELE check_login SP pathname CRLF + = { + if ($2 && $4 != NULL) + delete((char *) $4); + if ($4 != NULL) + free((char *) $4); + } + | RNTO SP pathname CRLF + = { + if (fromname) { + renamecmd(fromname, (char *) $3); + free(fromname); + fromname = (char *) 0; + } else { + reply(503, "Bad sequence of commands."); + } + free((char *) $3); + } + | ABOR CRLF + = { + reply(225, "ABOR command successful."); + } + | CWD check_login CRLF + = { + if ($2) + cwd(pw->pw_dir); + } + | CWD check_login SP pathname CRLF + = { + if ($2 && $4 != NULL) + cwd((char *) $4); + if ($4 != NULL) + free((char *) $4); + } + | HELP CRLF + = { + help(cmdtab, (char *) 0); + } + | HELP SP STRING CRLF + = { + register char *cp = (char *)$3; + + if (strncasecmp(cp, "SITE", 4) == 0) { + cp = (char *)$3 + 4; + if (*cp == ' ') + cp++; + if (*cp) + help(sitetab, cp); + else + help(sitetab, (char *) 0); + } else + help(cmdtab, (char *) $3); + } + | NOOP CRLF + = { + reply(200, "NOOP command successful."); + } + | MKD check_login SP pathname CRLF + = { + if ($2 && $4 != NULL) + makedir((char *) $4); + if ($4 != NULL) + free((char *) $4); + } + | RMD check_login SP pathname CRLF + = { + if ($2 && $4 != NULL) + removedir((char *) $4); + if ($4 != NULL) + free((char *) $4); + } + | PWD check_login CRLF + = { + if ($2) + pwd(); + } + | CDUP check_login CRLF + = { + if ($2) + cwd(".."); + } + | SITE SP HELP CRLF + = { + help(sitetab, (char *) 0); + } + | SITE SP HELP SP STRING CRLF + = { + help(sitetab, (char *) $5); + } + | SITE SP UMASK check_login CRLF + = { + int oldmask; + + if ($4) { + oldmask = umask(0); + (void) umask(oldmask); + reply(200, "Current UMASK is %03o", oldmask); + } + } + | SITE SP UMASK check_login SP octal_number CRLF + = { + int oldmask; + + if ($4) { + if (($6 == -1) || ($6 > 0777)) { + reply(501, "Bad UMASK value"); + } else { + oldmask = umask($6); + reply(200, + "UMASK set to %03o (was %03o)", + $6, oldmask); + } + } + } + | SITE SP CHMOD check_login SP octal_number SP pathname CRLF + = { + if ($4 && ($8 != NULL)) { + if ($6 > 0777) + reply(501, + "CHMOD: Mode value must be between 0 and 0777"); + else if (chmod((char *) $8, $6) < 0) + perror_reply(550, (char *) $8); + else + reply(200, "CHMOD command successful."); + } + if ($8 != NULL) + free((char *) $8); + } + | SITE SP IDLE CRLF + = { + reply(200, + "Current IDLE time limit is %d seconds; max %d", + timeout, maxtimeout); + } + | SITE SP IDLE SP NUMBER CRLF + = { + if ($5 < 30 || $5 > maxtimeout) { + reply(501, + "Maximum IDLE time must be between 30 and %d seconds", + maxtimeout); + } else { + timeout = $5; + (void) alarm((unsigned) timeout); + reply(200, + "Maximum IDLE time set to %d seconds", + timeout); + } + } + | STOU check_login SP pathname CRLF + = { + if ($2 && $4 != NULL) + store((char *) $4, "w", 1); + if ($4 != NULL) + free((char *) $4); + } + | SYST CRLF + = { +#ifdef unix +#ifdef BSD + reply(215, "UNIX Type: L%d Version: BSD-%d", + NBBY, BSD); +#else /* BSD */ + reply(215, "UNIX Type: L%d", NBBY); +#endif /* BSD */ +#else /* unix */ + reply(215, "UNKNOWN Type: L%d", NBBY); +#endif /* unix */ + } + + /* + * SIZE is not in RFC959, but Postel has blessed it and + * it will be in the updated RFC. + * + * Return size of file in a format suitable for + * using with RESTART (we just count bytes). + */ + | SIZE check_login SP pathname CRLF + = { + if ($2 && $4 != NULL) + sizecmd((char *) $4); + if ($4 != NULL) + free((char *) $4); + } + + /* + * MDTM is not in RFC959, but Postel has blessed it and + * it will be in the updated RFC. + * + * Return modification time of file as an ISO 3307 + * style time. E.g. YYYYMMDDHHMMSS or YYYYMMDDHHMMSS.xxx + * where xxx is the fractional second (of any precision, + * not necessarily 3 digits) + */ + | MDTM check_login SP pathname CRLF + = { + if ($2 && $4 != NULL) { + struct stat stbuf; + if (stat((char *) $4, &stbuf) < 0) + perror_reply(550, "%s", (char *) $4); + else if ((stbuf.st_mode&S_IFMT) != S_IFREG) { + reply(550, "%s: not a plain file.", + (char *) $4); + } else { + register struct tm *t; + struct tm *gmtime(); + t = gmtime(&stbuf.st_mtime); + reply(213, + "%04d%02d%02d%02d%02d%02d", + 1900 + t->tm_year, + t->tm_mon+1, t->tm_mday, + t->tm_hour, t->tm_min, t->tm_sec); + } + } + if ($4 != NULL) + free((char *) $4); + } + | QUIT CRLF + = { + reply(221, "Goodbye."); + dologout(0); + } + | error CRLF + = { + yyerrok; + } + ; +rcmd: RNFR check_login SP pathname CRLF + = { + char *renamefrom(); + + if ($2 && $4) { + fromname = renamefrom((char *) $4); + if (fromname == (char *) 0 && $4) { + free((char *) $4); + } + } + } + ; + +username: STRING + ; + +password: /* empty */ + = { + *(char **)&($$) = ""; + } + | STRING + ; + +byte_size: NUMBER + ; + +host_port: NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA + NUMBER COMMA NUMBER + = { + register char *a, *p; + + a = (char *)&data_dest.sin_addr; + a[0] = $1; a[1] = $3; a[2] = $5; a[3] = $7; + p = (char *)&data_dest.sin_port; + p[0] = $9; p[1] = $11; + data_dest.sin_family = AF_INET; + } + ; + +form_code: N + = { + $$ = FORM_N; + } + | T + = { + $$ = FORM_T; + } + | C + = { + $$ = FORM_C; + } + ; + +type_code: A + = { + cmd_type = TYPE_A; + cmd_form = FORM_N; + } + | A SP form_code + = { + cmd_type = TYPE_A; + cmd_form = $3; + } + | E + = { + cmd_type = TYPE_E; + cmd_form = FORM_N; + } + | E SP form_code + = { + cmd_type = TYPE_E; + cmd_form = $3; + } + | I + = { + cmd_type = TYPE_I; + } + | L + = { + cmd_type = TYPE_L; + cmd_bytesz = NBBY; + } + | L SP byte_size + = { + cmd_type = TYPE_L; + cmd_bytesz = $3; + } + /* this is for a bug in the BBN ftp */ + | L byte_size + = { + cmd_type = TYPE_L; + cmd_bytesz = $2; + } + ; + +struct_code: F + = { + $$ = STRU_F; + } + | R + = { + $$ = STRU_R; + } + | P + = { + $$ = STRU_P; + } + ; + +mode_code: S + = { + $$ = MODE_S; + } + | B + = { + $$ = MODE_B; + } + | C + = { + $$ = MODE_C; + } + ; + +pathname: pathstring + = { + /* + * Problem: this production is used for all pathname + * processing, but only gives a 550 error reply. + * This is a valid reply in some cases but not in others. + */ + if (logged_in && $1 && strncmp((char *) $1, "~", 1) == 0) { + *(char **)&($$) = *glob((char *) $1); + if (globerr != NULL) { + reply(550, globerr); + $$ = NULL; + } + free((char *) $1); + } else + $$ = $1; + } + ; + +pathstring: STRING + ; + +octal_number: NUMBER + = { + register int ret, dec, multby, digit; + + /* + * Convert a number that was read as decimal number + * to what it would be if it had been read as octal. + */ + dec = $1; + multby = 1; + ret = 0; + while (dec) { + digit = dec%10; + if (digit > 7) { + ret = -1; + break; + } + ret += digit * multby; + multby *= 8; + dec /= 10; + } + $$ = ret; + } + ; + +check_login: /* empty */ + = { + if (logged_in) + $$ = 1; + else { + reply(530, "Please login with USER and PASS."); + $$ = 0; + } + } + ; + +%% + +extern jmp_buf errcatch; + +#define CMD 0 /* beginning of command */ +#define ARGS 1 /* expect miscellaneous arguments */ +#define STR1 2 /* expect SP followed by STRING */ +#define STR2 3 /* expect STRING */ +#define OSTR 4 /* optional SP then STRING */ +#define ZSTR1 5 /* SP then optional STRING */ +#define ZSTR2 6 /* optional STRING after SP */ +#define SITECMD 7 /* SITE command */ +#define NSTR 8 /* Number followed by a string */ + +struct tab { + char *name; + short token; + short state; + short implemented; /* 1 if command is implemented */ + char *help; +}; + +struct tab cmdtab[] = { /* In order defined in RFC 765 */ + { "USER", USER, STR1, 1, " username" }, + { "PASS", PASS, ZSTR1, 1, " password" }, + { "ACCT", ACCT, STR1, 0, "(specify account)" }, + { "SMNT", SMNT, ARGS, 0, "(structure mount)" }, + { "REIN", REIN, ARGS, 0, "(reinitialize server state)" }, + { "QUIT", QUIT, ARGS, 1, "(terminate service)", }, + { "PORT", PORT, ARGS, 1, " b0, b1, b2, b3, b4" }, + { "PASV", PASV, ARGS, 1, "(set server in passive mode)" }, + { "TYPE", TYPE, ARGS, 1, " [ A | E | I | L ]" }, + { "STRU", STRU, ARGS, 1, "(specify file structure)" }, + { "MODE", MODE, ARGS, 1, "(specify transfer mode)" }, + { "RETR", RETR, STR1, 1, " file-name" }, + { "STOR", STOR, STR1, 1, " file-name" }, + { "APPE", APPE, STR1, 1, " file-name" }, + { "MLFL", MLFL, OSTR, 0, "(mail file)" }, + { "MAIL", MAIL, OSTR, 0, "(mail to user)" }, + { "MSND", MSND, OSTR, 0, "(mail send to terminal)" }, + { "MSOM", MSOM, OSTR, 0, "(mail send to terminal or mailbox)" }, + { "MSAM", MSAM, OSTR, 0, "(mail send to terminal and mailbox)" }, + { "MRSQ", MRSQ, OSTR, 0, "(mail recipient scheme question)" }, + { "MRCP", MRCP, STR1, 0, "(mail recipient)" }, + { "ALLO", ALLO, ARGS, 1, "allocate storage (vacuously)" }, + { "REST", REST, ARGS, 0, "(restart command)" }, + { "RNFR", RNFR, STR1, 1, " file-name" }, + { "RNTO", RNTO, STR1, 1, " file-name" }, + { "ABOR", ABOR, ARGS, 1, "(abort operation)" }, + { "DELE", DELE, STR1, 1, " file-name" }, + { "CWD", CWD, OSTR, 1, "[ directory-name ]" }, + { "XCWD", CWD, OSTR, 1, "[ directory-name ]" }, + { "LIST", LIST, OSTR, 1, "[ path-name ]" }, + { "NLST", NLST, OSTR, 1, "[ path-name ]" }, + { "SITE", SITE, SITECMD, 1, "site-cmd [ arguments ]" }, + { "SYST", SYST, ARGS, 1, "(get type of operating system)" }, + { "STAT", STAT, OSTR, 1, "[ path-name ]" }, + { "HELP", HELP, OSTR, 1, "[ ]" }, + { "NOOP", NOOP, ARGS, 1, "" }, + { "MKD", MKD, STR1, 1, " path-name" }, + { "XMKD", MKD, STR1, 1, " path-name" }, + { "RMD", RMD, STR1, 1, " path-name" }, + { "XRMD", RMD, STR1, 1, " path-name" }, + { "PWD", PWD, ARGS, 1, "(return current directory)" }, + { "XPWD", PWD, ARGS, 1, "(return current directory)" }, + { "CDUP", CDUP, ARGS, 1, "(change to parent directory)" }, + { "XCUP", CDUP, ARGS, 1, "(change to parent directory)" }, + { "STOU", STOU, STR1, 1, " file-name" }, + { "SIZE", SIZE, OSTR, 1, " path-name" }, + { "MDTM", MDTM, OSTR, 1, " path-name" }, + { NULL, 0, 0, 0, 0 } +}; + +struct tab sitetab[] = { + { "UMASK", UMASK, ARGS, 1, "[ umask ]" }, + { "IDLE", IDLE, ARGS, 1, "[ maximum-idle-time ]" }, + { "CHMOD", CHMOD, NSTR, 1, " mode file-name" }, + { "HELP", HELP, OSTR, 1, "[ ]" }, + { NULL, 0, 0, 0, 0 } +}; + +struct tab * +lookup(p, cmd) + register struct tab *p; + char *cmd; +{ + + for (; p->name != NULL; p++) + if (strcmp(cmd, p->name) == 0) + return (p); + return (0); +} + +#include + +/* + * getline - a hacked up version of fgets to ignore TELNET escape codes. + */ +char * +getline(s, n, iop) + char *s; + register FILE *iop; +{ + register c; + register char *cs; + + cs = s; +/* tmpline may contain saved command from urgent mode interruption */ + for (c = 0; tmpline[c] != '\0' && --n > 0; ++c) { + *cs++ = tmpline[c]; + if (tmpline[c] == '\n') { + *cs++ = '\0'; + if (debug) + syslog(LOG_DEBUG, "command: %s", s); + tmpline[0] = '\0'; + return(s); + } + if (c == 0) + tmpline[0] = '\0'; + } + while ((c = getc(iop)) != EOF) { + c &= 0377; + if (c == IAC) { + if ((c = getc(iop)) != EOF) { + c &= 0377; + switch (c) { + case WILL: + case WONT: + c = getc(iop); + printf("%c%c%c", IAC, DONT, 0377&c); + (void) fflush(stdout); + continue; + case DO: + case DONT: + c = getc(iop); + printf("%c%c%c", IAC, WONT, 0377&c); + (void) fflush(stdout); + continue; + case IAC: + break; + default: + continue; /* ignore command */ + } + } + } + *cs++ = c; + if (--n <= 0 || c == '\n') + break; + } + if (c == EOF && cs == s) + return (NULL); + *cs++ = '\0'; + if (debug) + syslog(LOG_DEBUG, "command: %s", s); + return (s); +} + +static int +toolong() +{ + time_t now; + extern char *ctime(); + extern time_t time(); + + reply(421, + "Timeout (%d seconds): closing control connection.", timeout); + (void) time(&now); + if (logging) { + syslog(LOG_INFO, + "User %s timed out after %d seconds at %s", + (pw ? pw -> pw_name : "unknown"), timeout, ctime(&now)); + } + dologout(1); +} + +yylex() +{ + static int cpos, state; + register char *cp, *cp2; + register struct tab *p; + int n; + char c, *strpbrk(); + char *copy(); + + for (;;) { + switch (state) { + + case CMD: + (void) signal(SIGALRM, toolong); + (void) alarm((unsigned) timeout); + if (getline(cbuf, sizeof(cbuf)-1, stdin) == NULL) { + reply(221, "You could at least say goodbye."); + dologout(0); + } + (void) alarm(0); +#ifdef SETPROCTITLE + if (strncasecmp(cbuf, "PASS", 4) != NULL) + setproctitle("%s: %s", proctitle, cbuf); +#endif /* SETPROCTITLE */ + if ((cp = index(cbuf, '\r'))) { + *cp++ = '\n'; + *cp = '\0'; + } + if ((cp = strpbrk(cbuf, " \n"))) + cpos = cp - cbuf; + if (cpos == 0) + cpos = 4; + c = cbuf[cpos]; + cbuf[cpos] = '\0'; + upper(cbuf); + p = lookup(cmdtab, cbuf); + cbuf[cpos] = c; + if (p != 0) { + if (p->implemented == 0) { + nack(p->name); + longjmp(errcatch,0); + /* NOTREACHED */ + } + state = p->state; + *(char **)&yylval = p->name; + return (p->token); + } + break; + + case SITECMD: + if (cbuf[cpos] == ' ') { + cpos++; + return (SP); + } + cp = &cbuf[cpos]; + if ((cp2 = strpbrk(cp, " \n"))) + cpos = cp2 - cbuf; + c = cbuf[cpos]; + cbuf[cpos] = '\0'; + upper(cp); + p = lookup(sitetab, cp); + cbuf[cpos] = c; + if (p != 0) { + if (p->implemented == 0) { + state = CMD; + nack(p->name); + longjmp(errcatch,0); + /* NOTREACHED */ + } + state = p->state; + *(char **)&yylval = p->name; + return (p->token); + } + state = CMD; + break; + + case OSTR: + if (cbuf[cpos] == '\n') { + state = CMD; + return (CRLF); + } + /* FALLTHROUGH */ + + case STR1: + case ZSTR1: + dostr1: + if (cbuf[cpos] == ' ') { + cpos++; + state = state == OSTR ? STR2 : ++state; + return (SP); + } + break; + + case ZSTR2: + if (cbuf[cpos] == '\n') { + state = CMD; + return (CRLF); + } + /* FALLTHROUGH */ + + case STR2: + cp = &cbuf[cpos]; + n = strlen(cp); + cpos += n - 1; + /* + * Make sure the string is nonempty and \n terminated. + */ + if (n > 1 && cbuf[cpos] == '\n') { + cbuf[cpos] = '\0'; + *(char **)&yylval = copy(cp); + cbuf[cpos] = '\n'; + state = ARGS; + return (STRING); + } + break; + + case NSTR: + if (cbuf[cpos] == ' ') { + cpos++; + return (SP); + } + if (isdigit(cbuf[cpos])) { + cp = &cbuf[cpos]; + while (isdigit(cbuf[++cpos])) + ; + c = cbuf[cpos]; + cbuf[cpos] = '\0'; + yylval = atoi(cp); + cbuf[cpos] = c; + state = STR1; + return (NUMBER); + } + state = STR1; + goto dostr1; + + case ARGS: + if (isdigit(cbuf[cpos])) { + cp = &cbuf[cpos]; + while (isdigit(cbuf[++cpos])) + ; + c = cbuf[cpos]; + cbuf[cpos] = '\0'; + yylval = atoi(cp); + cbuf[cpos] = c; + return (NUMBER); + } + switch (cbuf[cpos++]) { + + case '\n': + state = CMD; + return (CRLF); + + case ' ': + return (SP); + + case ',': + return (COMMA); + + case 'A': + case 'a': + return (A); + + case 'B': + case 'b': + return (B); + + case 'C': + case 'c': + return (C); + + case 'E': + case 'e': + return (E); + + case 'F': + case 'f': + return (F); + + case 'I': + case 'i': + return (I); + + case 'L': + case 'l': + return (L); + + case 'N': + case 'n': + return (N); + + case 'P': + case 'p': + return (P); + + case 'R': + case 'r': + return (R); + + case 'S': + case 's': + return (S); + + case 'T': + case 't': + return (T); + + } + break; + + default: + fatal("Unknown state in scanner."); + } + yyerror((char *) 0); + state = CMD; + longjmp(errcatch,0); + } +} + +upper(s) + register char *s; +{ + while (*s != '\0') { + if (islower(*s)) + *s = toupper(*s); + s++; + } +} + +char * +copy(s) + char *s; +{ + char *p; + extern char *malloc(), *strcpy(); + + p = malloc((unsigned) strlen(s) + 1); + if (p == NULL) + fatal("Ran out of memory."); + (void) strcpy(p, s); + return (p); +} + +help(ctab, s) + struct tab *ctab; + char *s; +{ + register struct tab *c; + register int width, NCMDS; + char *type; + + if (ctab == sitetab) + type = "SITE "; + else + type = ""; + width = 0, NCMDS = 0; + for (c = ctab; c->name != NULL; c++) { + int len = strlen(c->name); + + if (len > width) + width = len; + NCMDS++; + } + width = (width + 8) &~ 7; + if (s == 0) { + register int i, j, w; + int columns, lines; + + lreply(214, "The following %scommands are recognized %s.", + type, "(* =>'s unimplemented)"); + columns = 76 / width; + if (columns == 0) + columns = 1; + lines = (NCMDS + columns - 1) / columns; + for (i = 0; i < lines; i++) { + printf(" "); + for (j = 0; j < columns; j++) { + c = ctab + j * lines + i; + printf("%s%c", c->name, + c->implemented ? ' ' : '*'); + if (c + lines >= &ctab[NCMDS]) + break; + w = strlen(c->name) + 1; + while (w < width) { + putchar(' '); + w++; + } + } + printf("\r\n"); + } + (void) fflush(stdout); + reply(214, "Direct comments to ftp-bugs@%s.", hostname); + return; + } + upper(s); + c = lookup(ctab, s); + if (c == (struct tab *)0) { + reply(502, "Unknown command %s.", s); + return; + } + if (c->implemented) + reply(214, "Syntax: %s%s %s", type, c->name, c->help); + else + reply(214, "%s%-*s\t%s; unimplemented.", type, width, + c->name, c->help); +} + +sizecmd(filename) +char *filename; +{ + switch (type) { + case TYPE_L: + case TYPE_I: { + struct stat stbuf; + if (stat(filename, &stbuf) < 0 || + (stbuf.st_mode&S_IFMT) != S_IFREG) + reply(550, "%s: not a plain file.", filename); + else + reply(213, "%llu", (long long)stbuf.st_size); + break;} + case TYPE_A: { + FILE *fin; + register int c, count; + struct stat stbuf; + fin = fopen(filename, "r"); + if (fin == NULL) { + perror_reply(550, filename); + return; + } + if (fstat(fileno(fin), &stbuf) < 0 || + (stbuf.st_mode&S_IFMT) != S_IFREG) { + reply(550, "%s: not a plain file.", filename); + (void) fclose(fin); + return; + } + + count = 0; + while((c=getc(fin)) != EOF) { + if (c == '\n') /* will get expanded to \r\n */ + count++; + count++; + } + (void) fclose(fin); + + reply(213, "%ld", count); + break;} + default: + reply(504, "SIZE not implemented for Type %c.", "?AEIL"[type]); + } +} diff --git a/commands/byacc/verbose.c b/commands/yacc/verbose.c similarity index 60% rename from commands/byacc/verbose.c rename to commands/yacc/verbose.c index 2c7cc52c7..9272ecfbc 100644 --- a/commands/byacc/verbose.c +++ b/commands/yacc/verbose.c @@ -1,12 +1,65 @@ +/* $NetBSD: verbose.c,v 1.10 2009/04/14 09:41:31 lukem Exp $ */ + +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Robert Paul Corbett. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#if defined(__RCSID) && !defined(lint) +#if 0 +static char sccsid[] = "@(#)verbose.c 5.3 (Berkeley) 1/20/91"; +#else +__RCSID("$NetBSD: verbose.c,v 1.10 2009/04/14 09:41:31 lukem Exp $"); +#endif +#endif /* not lint */ #include "defs.h" - static short *null_rules; -verbose() +static void log_unused(void); +static void log_conflicts(void); +static void print_state(int); +static void print_conflicts(int); +static void print_core(int); +static void print_nulls(int); +static void print_actions(int); +static void print_shifts(action *); +static void print_reductions(action *, int); +static void print_gotos(int); + +void +verbose(void) { - register int i; + int i; if (!vflag) return; @@ -28,10 +81,11 @@ verbose() } -log_unused() +static void +log_unused(void) { - register int i; - register short *p; + int i; + short *p; fprintf(verbose_file, "\n\nRules never reduced:\n"); for (i = 3; i < nrules; ++i) @@ -47,9 +101,10 @@ log_unused() } -log_conflicts() +static void +log_conflicts(void) { - register int i; + int i; fprintf(verbose_file, "\n\n"); for (i = 0; i < nstates; i++) @@ -75,8 +130,8 @@ log_conflicts() } -print_state(state) -int state; +static void +print_state(int state) { if (state) fprintf(verbose_file, "\n\n"); @@ -89,11 +144,14 @@ int state; } -print_conflicts(state) -int state; +static void +print_conflicts(int state) { - register int symbol, act, number; - register action *p; + int symbol, act, number; + action *p; + + /* keep gcc -Wall happy. */ + act = number = 0; symbol = -1; for (p = parser[state]; p; p = p->next) @@ -137,15 +195,15 @@ int state; } -print_core(state) -int state; +static void +print_core(int state) { - register int i; - register int k; - register int rule; - register core *statep; - register short *sp; - register short *sp1; + int i; + int k; + int rule; + core *statep; + short *sp; + short *sp1; statep = state_table[state]; k = statep->nitems; @@ -173,11 +231,11 @@ int state; } -print_nulls(state) -int state; +static void +print_nulls(int state) { - register action *p; - register int i, j, k, nnulls; + action *p; + int i, j, k, nnulls; nnulls = 0; for (p = parser[state]; p; p = p->next) @@ -217,12 +275,12 @@ int state; } -print_actions(stateno) -int stateno; +static void +print_actions(int stateno) { - register action *p; - register shifts *sp; - register int as; + action *p; + shifts *sp; + int as; if (stateno == final_state) fprintf(verbose_file, "\t$end accept\n"); @@ -244,11 +302,11 @@ int stateno; } -print_shifts(p) -register action *p; +static void +print_shifts(action *p) { - register int count; - register action *q; + int count; + action *q; count = 0; for (q = p; q; q = q->next) @@ -269,12 +327,11 @@ register action *p; } -print_reductions(p, defred) -register action *p; -register int defred; +static void +print_reductions(action *p, int prdefred) { - register int k, anyreds; - register action *q; + int k, anyreds; + action *q; anyreds = 0; for (q = p; q ; q = q->next) @@ -292,7 +349,7 @@ register int defred; { for (; p; p = p->next) { - if (p->action_code == REDUCE && p->number != defred) + if (p->action_code == REDUCE && p->number != prdefred) { k = p->number - 2; if (p->suppressed == 0) @@ -301,29 +358,28 @@ register int defred; } } - if (defred > 0) - fprintf(verbose_file, "\t. reduce %d\n", defred - 2); + if (prdefred > 0) + fprintf(verbose_file, "\t. reduce %d\n", prdefred - 2); } } -print_gotos(stateno) -int stateno; +static void +print_gotos(int stateno) { - register int i, k; - register int as; - register short *to_state; - register shifts *sp; + int i, k; + int as; + short *state; + shifts *sp; putc('\n', verbose_file); sp = shift_table[stateno]; - to_state = sp->shift; + state = sp->shift; for (i = 0; i < sp->nshifts; ++i) { - k = to_state[i]; + k = state[i]; as = accessing_symbol[k]; if (ISVAR(as)) fprintf(verbose_file, "\t%s goto %d\n", symbol_name[as], k); } } - diff --git a/commands/yacc/warshall.c b/commands/yacc/warshall.c new file mode 100644 index 000000000..b667496bc --- /dev/null +++ b/commands/yacc/warshall.c @@ -0,0 +1,125 @@ +/* $NetBSD: warshall.c,v 1.8 2006/05/24 18:01:43 christos Exp $ */ + +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Robert Paul Corbett. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#if defined(__RCSID) && !defined(lint) +#if 0 +static char sccsid[] = "@(#)warshall.c 5.4 (Berkeley) 5/24/93"; +#else +__RCSID("$NetBSD: warshall.c,v 1.8 2006/05/24 18:01:43 christos Exp $"); +#endif +#endif /* not lint */ + +#include "defs.h" + +static void transitive_closure(unsigned *, int); + +static void +transitive_closure(unsigned *R, int n) +{ + int rowsize; + unsigned i; + unsigned *rowj; + unsigned *rp; + unsigned *rend; + unsigned *ccol; + unsigned *relend; + unsigned *cword; + unsigned *rowi; + + rowsize = WORDSIZE(n); + relend = R + n*rowsize; + + cword = R; + i = 0; + rowi = R; + while (rowi < relend) + { + ccol = cword; + rowj = R; + + while (rowj < relend) + { + if (*ccol & (1 << i)) + { + rp = rowi; + rend = rowj + rowsize; + while (rowj < rend) + *rowj++ |= *rp++; + } + else + { + rowj += rowsize; + } + + ccol += rowsize; + } + + if (++i >= BITS_PER_WORD) + { + i = 0; + cword++; + } + + rowi += rowsize; + } +} + +void +reflexive_transitive_closure(unsigned *R, int n) +{ + int rowsize; + unsigned i; + unsigned *rp; + unsigned *relend; + + transitive_closure(R, n); + + rowsize = WORDSIZE(n); + relend = R + n*rowsize; + + i = 0; + rp = R; + while (rp < relend) + { + *rp |= (1 << i); + if (++i >= BITS_PER_WORD) + { + i = 0; + rp++; + } + + rp += rowsize; + } +} diff --git a/commands/yacc/yacc.1 b/commands/yacc/yacc.1 new file mode 100644 index 000000000..fa317ee74 --- /dev/null +++ b/commands/yacc/yacc.1 @@ -0,0 +1,188 @@ +.\" $NetBSD: yacc.1,v 1.13 2003/08/07 11:17:55 agc Exp $ +.\" +.\" Copyright (c) 1989, 1990 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Robert Paul Corbett. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)yacc.1 5.7 (Berkeley) 7/30/91 +.\" $NetBSD: yacc.1,v 1.13 2003/08/07 11:17:55 agc Exp $ +.\" +.Dd July 30, 1991 +.Dt YACC 1 +.Os +.Sh NAME +.Nm yacc +.Nd an +.Tn LALR(1) +parser generator +.Sh SYNOPSIS +.Nm +.Op Fl dlrtv +.Op Fl b Ar prefix +.Op Fl o Ar outputfile +.Op Fl p Ar symbol_prefix +.Ar filename +.Sh DESCRIPTION +.Nm +reads the grammar specification in the file +.Ar filename +and generates an +.Tn LR(1) +parser for it. +The parsers consist of a set of +.Tn LALR(1) +parsing tables and a driver routine +written in the C programming language. +.Nm +normally writes the parse tables and the driver routine to the file +.Pa y.tab.c . +.Pp +The following options are available: +.Bl -tag -width Ar +.It Fl b Ar prefix +The +.Fl b +option changes the prefix prepended to the output file names to +the string denoted by +.Ar prefix . +The default prefix is the character +.Ar y . +.It Fl d +The +.Fl d +option causes the header file +.Pa y.tab.h +to be written. +.It Fl l +If the +.Fl l +option is not specified, +.Nm +will insert #line directives in the generated code. +The #line directives let the C compiler relate errors in the +generated code to the user's original code. +If the +.Fl l +option is specified, +.Nm +will not insert the #line directives. +#line directives specified by the user will be retained. +.It Fl o Ar outputfile +The +.Fl o +option specifies an explicit output file name should be used instead +of the default. +.It Fl p Ar symbol_prefix +The +.Fl p +option changes the prefix prepended to yacc-generated symbols to +the string denoted by +.Ar symbol_prefix . +The default prefix is the string +.Ar yy . +.It Fl r +The +.Fl r +option causes +.Nm +to produce separate files for code and tables. +The code file is named +.Pa y.code.c , +and the tables file is named +.Pa y.tab.c . +.It Fl t +The +.Fl t +option changes the preprocessor directives generated by +.Nm +so that debugging statements will be incorporated in the compiled code. +.It Fl v +The +.Fl v +option causes a human-readable description of the generated parser to +be written to the file +.Pa y.output . +.El +.Sh ENVIRONMENT +The following environment variable is referenced by +.Nm : +.Bl -tag -width TMPDIR +.It Ev TMPDIR +If the environment variable +.Ev TMPDIR +is set, the string denoted by +.Ev TMPDIR +will be used as the name of the directory where the temporary +files are created. +.El +.Sh TABLES +The names of the tables generated by this version of +.Nm +are +.Dq yylhs , +.Dq yylen , +.Dq yydefred , +.Dq yydgoto , +.Dq yysindex , +.Dq yyrindex , +.Dq yygindex , +.Dq yytable , +and +.Dq yycheck . +Two additional tables, +.Dq yyname +and +.Dq yyrule , +are created if +.Dv YYDEBUG +is defined and non-zero. +.Sh FILES +.Bl -tag -width /tmp/yacc.uXXXXXXXX -compact +.It Pa y.code.c +.It Pa y.tab.c +.It Pa y.tab.h +.It Pa y.output +.It Pa /tmp/yacc.aXXXXXX +.It Pa /tmp/yacc.tXXXXXX +.It Pa /tmp/yacc.uXXXXXX +.El +.Sh DIAGNOSTICS +If there are rules that are never reduced, the number of such rules is +written to the standard error. +If there are any +.Tn LALR(1) +conflicts, the number of conflicts is also written +to the standard error. +.\" .Sh SEE ALSO +.\" .Xr yyfix 1 +.Sh STANDARDS +The +.Nm +utility conforms to +.St -p1003.2 . diff --git a/commands/yap/Makefile b/commands/yap/Makefile index 14adf3baa..14b3148eb 100644 --- a/commands/yap/Makefile +++ b/commands/yap/Makefile @@ -1,210 +1,11 @@ -# $Header$ +# yap Makefile -# CFLAGS : options for the C-compiler -CFLAGS = -O -D_MINIX -D_POSIX_SOURCE -wa -CC=exec cc +PROG= yap +SRCS= assert.c commands.c display.c getcomm.c getline.c help.c \ + keys.c machine.c main.c options.c output.c pattern.c \ + process.c prompt.c term.c +CPPFLAGS+= -wa +LINKS+= ${BINDIR}/yap ${BINDIR}/more +MAN= -# LDFLAGS : flags for the loader -# -i for a PDP-11 with separate I/D (not necessary) -LDFLAGS = -i - -# BINDIR : where the binary will go when you type "make install" -BINDIR = /usr/bin - -# LIBRARIES : -ltermcap or -ltermlib, -# -lPW on USG systems (System III, System V), -# -ljobs on Berkeley Unix system (4.1, 2.8?, 2.9) -LIBRARIES = - -HFILES= assert.h\ - commands.h\ - display.h\ - getcomm.h\ - getline.h\ - help.h\ - in_all.h\ - keys.h\ - machine.h\ - main.h\ - options.h\ - output.h\ - pattern.h\ - process.h\ - prompt.h\ - term.h - -CFILES= assert.c\ - commands.c\ - display.c\ - getcomm.c\ - getline.c\ - help.c\ - keys.c\ - machine.c\ - main.c\ - options.c\ - output.c\ - pattern.c\ - process.c\ - prompt.c\ - term.c - -OFILES= assert.o\ - commands.o\ - display.o\ - getcomm.o\ - getline.o\ - help.o\ - keys.o\ - machine.o\ - main.o\ - options.o\ - output.o\ - pattern.o\ - process.o\ - prompt.o\ - term.o - -all: yap - -yap: $(OFILES) - $(CC) $(LDFLAGS) -o yap $(OFILES) $(LIBRARIES) - install -S 16kw yap - -install: $(BINDIR)/yap $(BINDIR)/more - -$(BINDIR)/yap: yap - install -cs -o bin yap $@ - -$(BINDIR)/more: $(BINDIR)/yap - install -l h $? $@ - -clean: - rm -f yap $(OFILES) a.out core *.bak - -pr: - pr Makefile $(HFILES) $(CFILES) - -lint: - lint $(DEFINES) $(CFILES) - -#AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO -assert.o: assert.h -assert.o: in_all.h -assert.o: output.h -assert.o: term.h -commands.o: assert.h -commands.o: commands.h -commands.o: display.h -commands.o: getcomm.h -commands.o: getline.h -commands.o: help.h -commands.o: in_all.h -commands.o: keys.h -commands.o: machine.h -commands.o: main.h -commands.o: options.h -commands.o: output.h -commands.o: pattern.h -commands.o: process.h -commands.o: prompt.h -commands.o: term.h -display.o: assert.h -display.o: display.h -display.o: getline.h -display.o: in_all.h -display.o: machine.h -display.o: main.h -display.o: options.h -display.o: output.h -display.o: process.h -display.o: term.h -getcomm.o: assert.h -getcomm.o: commands.h -getcomm.o: display.h -getcomm.o: getcomm.h -getcomm.o: getline.h -getcomm.o: in_all.h -getcomm.o: keys.h -getcomm.o: machine.h -getcomm.o: main.h -getcomm.o: output.h -getcomm.o: process.h -getcomm.o: prompt.h -getcomm.o: term.h -getline.o: assert.h -getline.o: display.h -getline.o: getline.h -getline.o: in_all.h -getline.o: main.h -getline.o: options.h -getline.o: output.h -getline.o: process.h -getline.o: term.h -help.o: commands.h -help.o: display.h -help.o: help.h -help.o: in_all.h -help.o: keys.h -help.o: machine.h -help.o: main.h -help.o: options.h -help.o: output.h -help.o: prompt.h -help.o: term.h -keys.o: assert.h -keys.o: commands.h -keys.o: in_all.h -keys.o: keys.h -keys.o: machine.h -keys.o: prompt.h -machine.o: assert.h -machine.o: getline.h -machine.o: in_all.h -machine.o: machine.h -main.o: commands.h -main.o: display.h -main.o: in_all.h -main.o: main.h -main.o: options.h -main.o: output.h -main.o: process.h -main.o: prompt.h -main.o: term.h -options.o: display.h -options.o: in_all.h -options.o: options.h -options.o: output.h -output.o: in_all.h -output.o: main.h -output.o: output.h -pattern.o: in_all.h -pattern.o: pattern.h -process.o: commands.h -process.o: display.h -process.o: getline.h -process.o: in_all.h -process.o: main.h -process.o: options.h -process.o: output.h -process.o: process.h -process.o: prompt.h -prompt.o: display.h -prompt.o: getcomm.h -prompt.o: getline.h -prompt.o: in_all.h -prompt.o: main.h -prompt.o: options.h -prompt.o: output.h -prompt.o: process.h -prompt.o: prompt.h -prompt.o: term.h -term.o: display.h -term.o: getline.h -term.o: in_all.h -term.o: keys.h -term.o: machine.h -term.o: main.h -term.o: options.h -term.o: output.h -term.o: term.h +.include diff --git a/commands/yap/build b/commands/yap/build deleted file mode 100755 index 2fb378086..000000000 --- a/commands/yap/build +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -set -e -make clean -make -make install diff --git a/commands/yap/pattern.c b/commands/yap/pattern.c index 8bf192695..80f1f93ed 100644 --- a/commands/yap/pattern.c +++ b/commands/yap/pattern.c @@ -2,7 +2,7 @@ # ifndef lint static char rcsid[] = "$Header$"; -# endif not lint +# endif /* not lint */ # define _PATTERN_ @@ -12,7 +12,7 @@ static char rcsid[] = "$Header$"; # if V8_REGEX # include -# endif V8_REGEX +# endif /* V8_REGEX */ /* * Interface to regular expression routines. @@ -22,12 +22,12 @@ static char rcsid[] = "$Header$"; # if USG_REGEX static char *pattern; /* Pointer to compiled pattern */ char *regcmp(), *regex(); -# endif USG_REGEX +# endif /* USG_REGEX */ # if V8_REGEX static struct regexp *pattern; static char *rc_error; struct regexp *regcomp(); -# endif V8_REGEX +# endif /* V8_REGEX */ # if USG_REGEX || V8_REGEX /* @@ -54,13 +54,13 @@ re_comp(s) char *s; { return (pattern = regcmp(s, (char *) 0)) ? (char *) 0 : "Error in pattern"; -# endif USG_REGEX +# endif /* USG_REGEX */ # if V8_REGEX pattern = regcomp(s); if (pattern) return (char *) 0; if (rc_error) return rc_error; return "Error in pattern"; -# endif V8_REGEX +# endif /* V8_REGEX */ } # if V8_REGEX @@ -68,7 +68,7 @@ VOID regerror(str) char *str; { rc_error = str; } -# endif V8_REGEX +# endif /* V8_REGEX */ /* * Search for compiled pattern in string "s". Return 0 if not found. @@ -78,14 +78,14 @@ re_exec(s) char *s; { # if USG_REGEX return !(regex(pattern,s) == 0); -# endif USG_REGEX +# endif /* USG_REGEX */ # if V8_REGEX # if _MINIX return regexec(pattern,s,1); # else return regexec(pattern,s); # endif -# endif V8_REGEX +# endif /* V8_REGEX */ } # else # ifndef BSD_REGEX @@ -156,5 +156,5 @@ re_exec(s) register char *s; { } return 0; /* Failure */ } -# endif not BSD_REGEX +# endif /* not BSD_REGEX */ # endif diff --git a/commands/yes/Makefile b/commands/yes/Makefile new file mode 100644 index 000000000..2a958fa13 --- /dev/null +++ b/commands/yes/Makefile @@ -0,0 +1,4 @@ +PROG= yes +MAN= + +.include diff --git a/commands/simple/yes.c b/commands/yes/yes.c similarity index 100% rename from commands/simple/yes.c rename to commands/yes/yes.c diff --git a/commands/zdump/Makefile b/commands/zdump/Makefile new file mode 100644 index 000000000..462b7a92b --- /dev/null +++ b/commands/zdump/Makefile @@ -0,0 +1,11 @@ +.include + +PROG= zdump +SRCS= zdump.c ialloc.c +TZDIR= /usr/share/zoneinfo +CPPFLAGS+= -DHAVE_ADJTIME=0 -DTZDIR=\"$(TZDIR)\" +MAN= zdump.8 + +.PATH: ${MINIXSRCDIR}/lib/libc/stdtime + +.include diff --git a/commands/zic/Makefile b/commands/zic/Makefile new file mode 100644 index 000000000..eb2093847 --- /dev/null +++ b/commands/zic/Makefile @@ -0,0 +1,11 @@ +.include + +PROG= zic +SRCS= zic.c scheck.c ialloc.c +TZDIR= /usr/share/zoneinfo +CPPFLAGS+= -DHAVE_ADJTIME=0 -DTZDIR=\"$(TZDIR)\" +MAN= zic.8 + +.PATH: ${MINIXSRCDIR}/lib/libc/stdtime + +.include diff --git a/commands/zmodem/Makefile b/commands/zmodem/Makefile index 72d640b27..d92d1486c 100644 --- a/commands/zmodem/Makefile +++ b/commands/zmodem/Makefile @@ -1,25 +1,8 @@ # Makefile for zmodem -all: rz sz +PROGS= rz sz +CPPFLAGS+= -DPOSIX -wo +MAN.rz= +MAN.sz= -CC = exec cc -CFLAGS= -DPOSIX -D_MINIX -D_POSIX_SOURCE -O -wo - -rz: rz.c rbsb.c zm.c zmodem.h - $(CC) $(CFLAGS) -i -o rz rz.c - install -S 5kw $@ - -sz: sz.c rbsb.c zm.c zmodem.h - $(CC) $(CFLAGS) -i -o sz sz.c - install -S 5kw $@ - -install: /usr/bin/rz /usr/bin/sz - -/usr/bin/rz: rz - install -cs -o bin rz $@ - -/usr/bin/sz: sz - install -cs -o bin sz $@ - -clean: - rm -f *.bak *.o core rz sz +.include diff --git a/commands/zmodem/build b/commands/zmodem/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/zmodem/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/zoneinfo/newctime.3 b/commands/zoneinfo/newctime.3 deleted file mode 120000 index 5203f2f5e..000000000 --- a/commands/zoneinfo/newctime.3 +++ /dev/null @@ -1 +0,0 @@ -../../man/man3/newctime.3 \ No newline at end of file diff --git a/commands/zoneinfo/newstrftime.3 b/commands/zoneinfo/newstrftime.3 deleted file mode 120000 index bebdb79eb..000000000 --- a/commands/zoneinfo/newstrftime.3 +++ /dev/null @@ -1 +0,0 @@ -../../man/man3/newstrftime.3 \ No newline at end of file diff --git a/commands/zoneinfo/newtzset.3 b/commands/zoneinfo/newtzset.3 deleted file mode 120000 index 53481c4be..000000000 --- a/commands/zoneinfo/newtzset.3 +++ /dev/null @@ -1 +0,0 @@ -../../man/man3/newtzset.3 \ No newline at end of file diff --git a/commands/zoneinfo/time2posix.3 b/commands/zoneinfo/time2posix.3 deleted file mode 120000 index 51d9e9c00..000000000 --- a/commands/zoneinfo/time2posix.3 +++ /dev/null @@ -1 +0,0 @@ -../../man/man3/time2posix.3 \ No newline at end of file diff --git a/commands/zoneinfo/tzfile.5 b/commands/zoneinfo/tzfile.5 deleted file mode 120000 index eb8856461..000000000 --- a/commands/zoneinfo/tzfile.5 +++ /dev/null @@ -1 +0,0 @@ -../../man/man5/tzfile.5 \ No newline at end of file diff --git a/commands/zoneinfo/tzselect.8 b/commands/zoneinfo/tzselect.8 deleted file mode 120000 index 1e7cb9d56..000000000 --- a/commands/zoneinfo/tzselect.8 +++ /dev/null @@ -1 +0,0 @@ -../../man/man8/tzselect.8 \ No newline at end of file diff --git a/commands/zoneinfo/zdump.8 b/commands/zoneinfo/zdump.8 deleted file mode 120000 index 5b9dbabaa..000000000 --- a/commands/zoneinfo/zdump.8 +++ /dev/null @@ -1 +0,0 @@ -../../man/man8/zdump.8 \ No newline at end of file diff --git a/commands/zoneinfo/zic.8 b/commands/zoneinfo/zic.8 deleted file mode 120000 index 16448e698..000000000 --- a/commands/zoneinfo/zic.8 +++ /dev/null @@ -1 +0,0 @@ -../../man/man8/zic.8 \ No newline at end of file diff --git a/docs/UPDATING b/docs/UPDATING index 3d7e17e90..75de762b2 100644 --- a/docs/UPDATING +++ b/docs/UPDATING @@ -1,3 +1,10 @@ +20100512: + yacc and lex updated + # make includes + # cd commands/yacc + # make depend all install + # cd commands/lex + # LEX=flex make depend all install 20100506: /usr/src/etc/usr/rc updated: copy it (or merge it) to /usr/etc/rc. 20100410: diff --git a/drivers/memory/ramdisk/Makefile b/drivers/memory/ramdisk/Makefile index ff9ee3a00..63d171278 100644 --- a/drivers/memory/ramdisk/Makefile +++ b/drivers/memory/ramdisk/Makefile @@ -46,35 +46,35 @@ pci: ../../pci/pci ../../pci/pci: cd ../../pci && make -cdprobe: ../../../commands/simple/cdprobe - install -s ../../../commands/simple/$@ $@ +cdprobe: ../../../commands/cdprobe/cdprobe + install -s ../../../commands/$@/$@ $@ -../../../commands/simple/cdprobe: - cd ../../../commands/simple && make cdprobe +../../../commands/cdprobe: + cd ../../../commands/cdprobe && make -dev2name: ../../../commands/simple/dev2name - install -s ../../../commands/simple/$@ $@ +dev2name: ../../../commands/dev2name/dev2name + install -s ../../../commands/$@/$@ $@ -../../../commands/simple/dev2name: - cd ../../../commands/simple && make dev2name +../../../commands/dev2name/dev2name: + cd ../../../commands/dev2name && make -loadramdisk: ../../../commands/simple/loadramdisk - install -s ../../../commands/simple/$@ $@ +loadramdisk: ../../../commands/loadramdisk/loadramdisk + install -s ../../../commands/$@/$@ $@ -../../../commands/simple/loadramdisk: - cd ../../../commands/simple && make loadramdisk +../../../commands/loadramdisk/loadramdisk: + cd ../../../commands/loadramdisk && make -newroot: ../../../commands/simple/newroot - install -s ../../../commands/simple/$@ $@ +newroot: ../../../commands/newroot/newroot + install -s ../../../commands/$@/$@ $@ -../../../commands/simple/newroot: - cd ../../../commands/simple && make newroot +../../../commands/newroot/newroot: + cd ../../../commands/newroot && make -sysenv: ../../../commands/simple/sysenv - install -s ../../../commands/simple/$@ $@ +sysenv: ../../../commands/sysenv/sysenv + install -s ../../../commands/$@/$@ $@ -../../../commands/simple/sysenv: - cd ../../../commands/simple && make sysenv +../../../commands/sysenv: + cd ../../../commands/sysenv && make sh: ../../../commands/ash/sh install -s ../../../commands/ash/$@ $@ diff --git a/drivers/tty/keymaps/Makefile.inc b/drivers/tty/keymaps/Makefile.inc index b6885d4aa..d2fc98619 100644 --- a/drivers/tty/keymaps/Makefile.inc +++ b/drivers/tty/keymaps/Makefile.inc @@ -1,4 +1,4 @@ -FILESDIR= ${DESTDIR}/usr/lib/keymaps +FILESDIR= /usr/lib/keymaps .SUFFIXES: .src .map @@ -10,5 +10,4 @@ FILESDIR= ${DESTDIR}/usr/lib/keymaps realall: ${FILES} -clean: - rm -f ${FILES} +CLEANFILES+= ${FILES} diff --git a/etc/Makefile b/etc/Makefile index f900393b2..eb4eb6b21 100644 --- a/etc/Makefile +++ b/etc/Makefile @@ -25,15 +25,15 @@ install:: rm $(ETC)/$(DIR1)/* cp $(DIR1)/*.mk $(ETC)/$(DIR1) chmod 644 $(ETC)/$(DIR1)/* - chown bin $(ETC)/$(DIR1)/* + chown root $(ETC)/$(DIR1)/* @echo "Making devices.." - p=`pwd` && cd /dev && sh $$p/../commands/scripts/MAKEDEV.sh null - p=`pwd` && cd /dev && sh $$p/../commands/scripts/MAKEDEV.sh std 2>/dev/null - install -o bin -g operator -m 755 crontab /usr/lib + p=`pwd` && cd /dev && sh $$p/../commands/MAKEDEV/MAKEDEV.sh null + p=`pwd` && cd /dev && sh $$p/../commands/MAKEDEV/MAKEDEV.sh std 2>/dev/null + install -o root -g operator -m 755 crontab /usr/lib @echo "Making user homedirs.." for u in /usr/ast ~root; do cp ast/.[aepv]* $$u ; done @echo "Installing fonts.." - install -m 644 -o bin -g operator fonts/*.fnt /usr/lib/fonts/ + install -m 644 -o root -g operator fonts/*.fnt /usr/lib/fonts/ postinstall: binsizes normal diff --git a/etc/mk/minix.ack.mk b/etc/mk/minix.ack.mk index 6f060aca1..345199f84 100644 --- a/etc/mk/minix.ack.mk +++ b/etc/mk/minix.ack.mk @@ -9,7 +9,7 @@ # .endif ASMCONV=gas2ack -AFLAGS+=-D__ASSEMBLY__ -D_EM_WSIZE=4 -D__minix -w -wo +AFLAGS+=-D__ASSEMBLY__ -D__minix -w -wo CPP.s=${CC} -E ${AFLAGS} ASMCONVFLAGS+=-mi386 diff --git a/etc/mk/minix.inc.mk b/etc/mk/minix.inc.mk index c0fffaf2b..817102311 100644 --- a/etc/mk/minix.inc.mk +++ b/etc/mk/minix.inc.mk @@ -42,16 +42,26 @@ incinstall:: ${_F} inclinkinstall: .PHONY .if !empty(INCSYMLINKS) +# XXX: Minix can't handle stat -qf +# @(set ${INCSYMLINKS}; \ +# while test $$# -ge 2; do \ +# l=$$1; shift; \ +# t=${DESTDIR}$$1; shift; \ +# if ttarg=`${TOOL_STAT} -qf '%Y' $$t` && \ +# [ "$$l" = "$$ttarg" ]; then \ +# continue ; \ +# fi ; \ +# ${_MKSHMSG_INSTALL} $$t; \ +# ${_MKSHECHO} ${INSTALL_SYMLINK} $$l $$t; \ +# ${INSTALL_SYMLINK} $$l $$t; \ +# done; ) @(set ${INCSYMLINKS}; \ while test $$# -ge 2; do \ l=$$1; shift; \ t=${DESTDIR}$$1; shift; \ - if ttarg=`${TOOL_STAT} -qf '%Y' $$t` && \ - [ "$$l" = "$$ttarg" ]; then \ - continue ; \ - fi ; \ ${_MKSHMSG_INSTALL} $$t; \ ${_MKSHECHO} ${INSTALL_SYMLINK} $$l $$t; \ ${INSTALL_SYMLINK} $$l $$t; \ done; ) + .endif diff --git a/etc/mk/minix.own.mk b/etc/mk/minix.own.mk index ed303a869..050e8e6c7 100644 --- a/etc/mk/minix.own.mk +++ b/etc/mk/minix.own.mk @@ -455,8 +455,8 @@ NETBSDSRCDIR?= ${BSDSRCDIR} #BINGRP?= wheel BINGRP?= operator BINOWN?= root -BINMODE?= 555 -NONBINMODE?= 444 +BINMODE?= 755 +NONBINMODE?= 644 #MANDIR?= /usr/share/man MANDIR?= /usr/man diff --git a/etc/mk/minix.prog.mk b/etc/mk/minix.prog.mk index 51c55daaf..4f2451b72 100644 --- a/etc/mk/minix.prog.mk +++ b/etc/mk/minix.prog.mk @@ -1,4 +1,4 @@ -# $NetBSD: bsd.prog.mk,v 1.243 2009/11/27 11:44:36 tsutsui Exp $ +# $NetBSD: bsd.prog.mk,v 1.244 2009/12/08 15:18:42 uebayasi Exp $ # @(#)bsd.prog.mk 8.2 (Berkeley) 4/2/94 .ifndef HOSTPROG @@ -174,18 +174,7 @@ _PROGDEBUG.${_P}:= ${PROGNAME.${_P}}.debug .endif ##### PROG specific flags. -COPTS+= ${COPTS.${_P}} -CPPFLAGS+= ${CPPFLAGS.${_P}} -CXXFLAGS+= ${CXXFLAGS.${_P}} -OBJCOPTS+= ${OBJCOPTS.${_P}} -LDADD+= ${LDADD.${_P}} -LDFLAGS+= ${LDFLAGS.${_P}} -LDSTATIC+= ${LDSTATIC.${_P}} -_COPTS.${_P}= ${COPTS} ${COPTS.${_P}} -_CPPFLAGS.${_P}= ${CPPFLAGS} ${CPPFLAGS.${_P}} -_CXXFLAGS.${_P}= ${CXXFLAGS} ${CXXFLAGS.${_P}} -_OBJCOPTS.${_P}= ${OBJCOPTS} ${OBJCOPTS.${_P}} _LDADD.${_P}= ${LDADD} ${LDADD.${_P}} _LDFLAGS.${_P}= ${LDFLAGS} ${LDFLAGS.${_P}} _LDSTATIC.${_P}= ${LDSTATIC} ${LDSTATIC.${_P}} diff --git a/etc/mtree/minix.tree b/etc/mtree/minix.tree index 4a78a43cb..f66a6be2a 100644 --- a/etc/mtree/minix.tree +++ b/etc/mtree/minix.tree @@ -1,10 +1,10 @@ 755 root operator / -755 bin operator /bin -755 bin operator /sbin +755 root operator /bin +755 root operator /sbin 755 root operator /dev /dev/mouse -> /dev/kbdaux 755 root operator /etc -755 root bin /etc/mk +755 root operator /etc/mk 755 root operator /boot 755 root operator /boot/image 555 root operator /mnt @@ -14,16 +14,16 @@ 755 root operator /usr/adm 755 root operator /usr/adm/old 755 ast other /usr/ast -755 bin operator /usr/bin +755 root operator /usr/bin 755 root operator /usr/etc 755 root operator /home -755 bin operator /usr/include -755 bin operator /usr/include/arpa -755 bin operator /usr/include/minix -755 bin operator /usr/include/net -755 bin operator /usr/include/net/gen -755 bin operator /usr/include/netinet -755 bin operator /usr/include/sys +755 root operator /usr/include +755 root operator /usr/include/arpa +755 root operator /usr/include/minix +755 root operator /usr/include/net +755 root operator /usr/include/net/gen +755 root operator /usr/include/netinet +755 root operator /usr/include/sys 755 root operator /usr/lib 755 root operator /usr/lib/advent 755 root operator /usr/lib/cawf @@ -34,49 +34,49 @@ 755 root operator /usr/lib/i86 755 root operator /usr/lib/keymaps 755 root operator /usr/lib/m2 -755 bin operator /usr/lib/oss -755 bin operator /usr/lib/oss/conf -755 bin operator /usr/lib/oss/etc +755 root operator /usr/lib/oss +755 root operator /usr/lib/oss/conf +755 root operator /usr/lib/oss/etc 755 root operator /usr/sbin -775 bin operator /usr/local -775 bin operator /usr/local/bin -775 bin operator /usr/local/etc -775 bin operator /usr/local/etc/rc.d -775 bin operator /usr/local/include -775 bin operator /usr/local/info -775 bin operator /usr/local/lib -775 bin operator /usr/local/lib/ack -775 bin operator /usr/local/lib/gcc -775 bin operator /usr/local/man -775 bin operator /usr/local/src -755 bin operator /usr/local/man/man1 -755 bin operator /usr/local/man/man2 -755 bin operator /usr/local/man/man3 -755 bin operator /usr/local/man/man4 -755 bin operator /usr/local/man/man5 -755 bin operator /usr/local/man/man6 -755 bin operator /usr/local/man/man7 -755 bin operator /usr/local/man/man8 -755 bin operator /usr/local/man/man9 -775 bin operator /usr/local/packages -775 bin operator /usr/local/share -775 bin operator /usr/local/src -755 bin operator /usr/man -755 bin operator /usr/man/man1 -755 bin operator /usr/man/man1x -755 bin operator /usr/man/man2 -755 bin operator /usr/man/man3 -755 bin operator /usr/man/man4 -755 bin operator /usr/man/man5 -755 bin operator /usr/man/man6 -755 bin operator /usr/man/man7 -755 bin operator /usr/man/man8 -755 bin operator /usr/man/man9 -755 bin operator /usr/mdec +775 root operator /usr/local +775 root operator /usr/local/bin +775 root operator /usr/local/etc +775 root operator /usr/local/etc/rc.d +775 root operator /usr/local/include +775 root operator /usr/local/info +775 root operator /usr/local/lib +775 root operator /usr/local/lib/ack +775 root operator /usr/local/lib/gcc +775 root operator /usr/local/man +775 root operator /usr/local/src +755 root operator /usr/local/man/man1 +755 root operator /usr/local/man/man2 +755 root operator /usr/local/man/man3 +755 root operator /usr/local/man/man4 +755 root operator /usr/local/man/man5 +755 root operator /usr/local/man/man6 +755 root operator /usr/local/man/man7 +755 root operator /usr/local/man/man8 +755 root operator /usr/local/man/man9 +775 root operator /usr/local/packages +775 root operator /usr/local/share +775 root operator /usr/local/src +755 root operator /usr/man +755 root operator /usr/man/man1 +755 root operator /usr/man/man1x +755 root operator /usr/man/man2 +755 root operator /usr/man/man3 +755 root operator /usr/man/man4 +755 root operator /usr/man/man5 +755 root operator /usr/man/man6 +755 root operator /usr/man/man7 +755 root operator /usr/man/man8 +755 root operator /usr/man/man9 +755 root operator /usr/mdec 700 root operator /usr/preserve 755 root operator /usr/run -755 bin operator /usr/share -755 bin operator /usr/share/zoneinfo +755 root operator /usr/share +755 root operator /usr/share/zoneinfo 755 root operator /usr/spool 711 root operator /usr/spool/at 711 root operator /usr/spool/at/past @@ -84,7 +84,7 @@ 775 root uucp /usr/spool/locks 700 daemon daemon /usr/spool/lpd 755 root operator /usr/spool/mail -755 bin operator /usr/src +755 root operator /usr/src 1777 root operator /usr/tmp 755 root operator /var /var/log -> /usr/log diff --git a/include/sys/Makefile b/include/sys/Makefile index 0ac955c2b..e6c948ca3 100644 --- a/include/sys/Makefile +++ b/include/sys/Makefile @@ -9,6 +9,6 @@ INCS= asynchio.h dir.h file.h ioc_cmos.h ioc_disk.h \ select.h sem.h shm.h sigcontext.h signal.h socket.h \ soundcard.h statfs.h stat.h svrctl.h timeb.h \ time.h times.h types.h ucontext.h uio.h un.h utsname.h video.h vm.h \ - wait.h + wait.h cdefs.h .include diff --git a/include/sys/cdefs.h b/include/sys/cdefs.h new file mode 100644 index 000000000..cc7a905be --- /dev/null +++ b/include/sys/cdefs.h @@ -0,0 +1,450 @@ +/* $NetBSD: cdefs.h,v 1.78 2009/10/02 21:05:28 christos Exp $ */ + +/* + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Berkeley Software Design, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)cdefs.h 8.8 (Berkeley) 1/9/95 + */ + +#ifndef _SYS_CDEFS_H_ +#define _SYS_CDEFS_H_ + +/* + * Macro to test if we're using a GNU C compiler of a specific vintage + * or later, for e.g. features that appeared in a particular version + * of GNU C. Usage: + * + * #if __GNUC_PREREQ__(major, minor) + * ...cool feature... + * #else + * ...delete feature... + * #endif + */ +#ifdef __GNUC__ +#define __GNUC_PREREQ__(x, y) \ + ((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) || \ + (__GNUC__ > (x))) +#else +#define __GNUC_PREREQ__(x, y) 0 +#endif + +#if 0 +#include +#ifdef __ELF__ +#include +#else +#include +#endif +#endif + +#if defined(__cplusplus) +#define __BEGIN_DECLS extern "C" { +#define __END_DECLS } +#define __static_cast(x,y) static_cast(y) +#else +#define __BEGIN_DECLS +#define __END_DECLS +#define __static_cast(x,y) (x)y +#endif + +/* + * The __CONCAT macro is used to concatenate parts of symbol names, e.g. + * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. + * The __CONCAT macro is a bit tricky -- make sure you don't put spaces + * in between its arguments. __CONCAT can also concatenate double-quoted + * strings produced by the __STRING macro, but this only works with ANSI C. + */ + +#define ___STRING(x) __STRING(x) +#define ___CONCAT(x,y) __CONCAT(x,y) + +#if __STDC__ || defined(__cplusplus) +#define __P(protos) protos /* full-blown ANSI C */ +#define __CONCAT(x,y) x ## y +#define __STRING(x) #x + +#define __const const /* define reserved names to standard */ +#define __signed signed +#define __volatile volatile +#if defined(__cplusplus) || defined(__PCC__) +#define __inline inline /* convert to C++/C99 keyword */ +#else +#if !defined(__GNUC__) && !defined(__lint__) +#define __inline /* delete GCC keyword */ +#endif /* !__GNUC__ && !__lint__ */ +#endif /* !__cplusplus */ + +#else /* !(__STDC__ || __cplusplus) */ +#define __P(protos) () /* traditional C preprocessor */ +#define __CONCAT(x,y) x/**/y +#define __STRING(x) "x" + +#ifndef __GNUC__ +#define __const /* delete pseudo-ANSI C keywords */ +#define __inline +#define __signed +#define __volatile +#endif /* !__GNUC__ */ + +/* + * In non-ANSI C environments, new programs will want ANSI-only C keywords + * deleted from the program and old programs will want them left alone. + * Programs using the ANSI C keywords const, inline etc. as normal + * identifiers should define -DNO_ANSI_KEYWORDS. + */ +#ifndef NO_ANSI_KEYWORDS +#define const __const /* convert ANSI C keywords */ +#define inline __inline +#define signed __signed +#define volatile __volatile +#endif /* !NO_ANSI_KEYWORDS */ +#endif /* !(__STDC__ || __cplusplus) */ + +/* + * Used for internal auditing of the NetBSD source tree. + */ +#ifdef __AUDIT__ +#define __aconst __const +#else +#define __aconst +#endif + +/* + * The following macro is used to remove const cast-away warnings + * from gcc -Wcast-qual; it should be used with caution because it + * can hide valid errors; in particular most valid uses are in + * situations where the API requires it, not to cast away string + * constants. We don't use *intptr_t on purpose here and we are + * explicit about unsigned long so that we don't have additional + * dependencies. + */ +#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a)) + +/* + * The following macro is used to remove the volatile cast-away warnings + * from gcc -Wcast-qual; as above it should be used with caution + * because it can hide valid errors or warnings. Valid uses include + * making it possible to pass a volatile pointer to memset(). + * For the same reasons as above, we use unsigned long and not intptr_t. + */ +#define __UNVOLATILE(a) ((void *)(unsigned long)(volatile void *)(a)) + +/* + * GCC2 provides __extension__ to suppress warnings for various GNU C + * language extensions under "-ansi -pedantic". + */ +#if !__GNUC_PREREQ__(2, 0) +#define __extension__ /* delete __extension__ if non-gcc or gcc1 */ +#endif + +/* + * GCC1 and some versions of GCC2 declare dead (non-returning) and + * pure (no side effects) functions using "volatile" and "const"; + * unfortunately, these then cause warnings under "-ansi -pedantic". + * GCC2 uses a new, peculiar __attribute__((attrs)) style. All of + * these work for GNU C++ (modulo a slight glitch in the C++ grammar + * in the distribution version of 2.5.5). + * + * GCC defines a pure function as depending only on its arguments and + * global variables. Typical examples are strlen and sqrt. + * + * GCC defines a const function as depending only on its arguments. + * Therefore calling a const function again with identical arguments + * will always produce the same result. + * + * Rounding modes for floating point operations are considered global + * variables and prevent sqrt from being a const function. + * + * Calls to const functions can be optimised away and moved around + * without limitations. + */ +#if !__GNUC_PREREQ__(2, 0) +#define __attribute__(x) +#endif + +#if __GNUC_PREREQ__(2, 5) +#define __dead __attribute__((__noreturn__)) +#elif defined(__GNUC__) +#define __dead __volatile +#else +#define __dead +#endif + +#if __GNUC_PREREQ__(2, 96) +#define __pure __attribute__((__pure__)) +#elif defined(__GNUC__) +#define __pure __const +#else +#define __pure +#endif + +#if __GNUC_PREREQ__(2, 5) +#define __constfunc __attribute__((__const__)) +#else +#define __constfunc +#endif + +#if __GNUC_PREREQ__(3, 0) +#define __noinline __attribute__((__noinline__)) +#else +#define __noinline /* nothing */ +#endif + +#if __GNUC_PREREQ__(2, 7) +#define __unused __attribute__((__unused__)) +#else +#define __unused /* delete */ +#endif + +#if __GNUC_PREREQ__(3, 1) +#define __used __attribute__((__used__)) +#else +#define __used __unused +#endif + +#if defined(__lint__) +#define __packed __packed +#define __aligned(x) /* delete */ +#define __section(x) /* delete */ +#elif __GNUC_PREREQ__(2, 7) +#define __packed __attribute__((__packed__)) +#define __aligned(x) __attribute__((__aligned__(x))) +#define __section(x) __attribute__((__section__(x))) +#elif defined(__PCC__) +#define __packed _Pragma("packed 1") +#define __aligned(x) _Pragma("aligned " __STRING(x)) +#define __section(x) _Pragma("section " ## x) +#else +#define __packed error: no __packed for this compiler +#define __aligned(x) error: no __aligned for this compiler +#define __section(x) error: no __section for this compiler +#endif + +/* + * C99 defines the restrict type qualifier keyword, which was made available + * in GCC 2.92. + */ +#if defined(__lint__) +#define __restrict /* delete __restrict when not supported */ +#elif __STDC_VERSION__ >= 199901L +#define __restrict restrict +#elif !__GNUC_PREREQ__(2, 92) +#define __restrict /* delete __restrict when not supported */ +#endif + +/* + * C99 defines __func__ predefined identifier, which was made available + * in GCC 2.95. + */ +#if !(__STDC_VERSION__ >= 199901L) +#if __GNUC_PREREQ__(2, 6) +#define __func__ __PRETTY_FUNCTION__ +#elif __GNUC_PREREQ__(2, 4) +#define __func__ __FUNCTION__ +#else +#define __func__ "" +#endif +#endif /* !(__STDC_VERSION__ >= 199901L) */ + +#if defined(_KERNEL) +#if defined(NO_KERNEL_RCSIDS) +#undef __KERNEL_RCSID +#define __KERNEL_RCSID(_n, _s) /* nothing */ +#endif /* NO_KERNEL_RCSIDS */ +#endif /* _KERNEL */ + +#if 0 +#if !defined(_STANDALONE) && !defined(_KERNEL) +#if defined(__GNUC__) || defined(__PCC__) +#define __RENAME(x) ___RENAME(x) +#else +#ifdef __lint__ +#define __RENAME(x) __symbolrename(x) +#else +#error "No function renaming possible" +#endif /* __lint__ */ +#endif /* __GNUC__ */ +#else /* _STANDALONE || _KERNEL */ +#define __RENAME(x) no renaming in kernel or standalone environment +#endif +#endif +/* + * A barrier to stop the optimizer from moving code or assume live + * register values. This is gcc specific, the version is more or less + * arbitrary, might work with older compilers. + */ +#if __GNUC_PREREQ__(2, 95) +#define __insn_barrier() __asm __volatile("":::"memory") +#else +#define __insn_barrier() /* */ +#endif + +/* + * GNU C version 2.96 adds explicit branch prediction so that + * the CPU back-end can hint the processor and also so that + * code blocks can be reordered such that the predicted path + * sees a more linear flow, thus improving cache behavior, etc. + * + * The following two macros provide us with a way to use this + * compiler feature. Use __predict_true() if you expect the expression + * to evaluate to true, and __predict_false() if you expect the + * expression to evaluate to false. + * + * A few notes about usage: + * + * * Generally, __predict_false() error condition checks (unless + * you have some _strong_ reason to do otherwise, in which case + * document it), and/or __predict_true() `no-error' condition + * checks, assuming you want to optimize for the no-error case. + * + * * Other than that, if you don't know the likelihood of a test + * succeeding from empirical or other `hard' evidence, don't + * make predictions. + * + * * These are meant to be used in places that are run `a lot'. + * It is wasteful to make predictions in code that is run + * seldomly (e.g. at subsystem initialization time) as the + * basic block reordering that this affects can often generate + * larger code. + */ +#if __GNUC_PREREQ__(2, 96) +#define __predict_true(exp) __builtin_expect((exp) != 0, 1) +#define __predict_false(exp) __builtin_expect((exp) != 0, 0) +#else +#define __predict_true(exp) (exp) +#define __predict_false(exp) (exp) +#endif + +/* + * Compiler-dependent macros to declare that functions take printf-like + * or scanf-like arguments. They are null except for versions of gcc + * that are known to support the features properly (old versions of gcc-2 + * didn't permit keeping the keywords out of the application namespace). + */ +#if __GNUC_PREREQ__(2, 7) +#define __printflike(fmtarg, firstvararg) \ + __attribute__((__format__ (__printf__, fmtarg, firstvararg))) +#define __scanflike(fmtarg, firstvararg) \ + __attribute__((__format__ (__scanf__, fmtarg, firstvararg))) +#define __format_arg(fmtarg) __attribute__((__format_arg__ (fmtarg))) +#else +#define __printflike(fmtarg, firstvararg) /* nothing */ +#define __scanflike(fmtarg, firstvararg) /* nothing */ +#define __format_arg(fmtarg) /* nothing */ +#endif + +/* + * Macros for manipulating "link sets". Link sets are arrays of pointers + * to objects, which are gathered up by the linker. + * + * Object format-specific code has provided us with the following macros: + * + * __link_set_add_text(set, sym) + * Add a reference to the .text symbol `sym' to `set'. + * + * __link_set_add_rodata(set, sym) + * Add a reference to the .rodata symbol `sym' to `set'. + * + * __link_set_add_data(set, sym) + * Add a reference to the .data symbol `sym' to `set'. + * + * __link_set_add_bss(set, sym) + * Add a reference to the .bss symbol `sym' to `set'. + * + * __link_set_decl(set, ptype) + * Provide an extern declaration of the set `set', which + * contains an array of the pointer type `ptype'. This + * macro must be used by any code which wishes to reference + * the elements of a link set. + * + * __link_set_start(set) + * This points to the first slot in the link set. + * + * __link_set_end(set) + * This points to the (non-existent) slot after the last + * entry in the link set. + * + * __link_set_count(set) + * Count the number of entries in link set `set'. + * + * In addition, we provide the following macros for accessing link sets: + * + * __link_set_foreach(pvar, set) + * Iterate over the link set `set'. Because a link set is + * an array of pointers, pvar must be declared as "type **pvar", + * and the actual entry accessed as "*pvar". + * + * __link_set_entry(set, idx) + * Access the link set entry at index `idx' from set `set'. + */ +#define __link_set_foreach(pvar, set) \ + for (pvar = __link_set_start(set); pvar < __link_set_end(set); pvar++) + +#define __link_set_entry(set, idx) (__link_set_begin(set)[idx]) + +/* + * Return the number of elements in a statically-allocated array, + * __x. + */ +#define __arraycount(__x) (sizeof(__x) / sizeof(__x[0])) + +/* __BIT(n): nth bit, where __BIT(0) == 0x1. */ +#define __BIT(__n) \ + (((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : ((uintmax_t)1 << (uintmax_t)(__n))) + +/* __BITS(m, n): bits m through n, m < n. */ +#define __BITS(__m, __n) \ + ((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1)) + +/* find least significant bit that is set */ +#define __LOWEST_SET_BIT(__mask) ((((__mask) - 1) & (__mask)) ^ (__mask)) + +#define __PRIuBIT PRIuMAX +#define __PRIuBITS __PRIuBIT + +#define __PRIxBIT PRIxMAX +#define __PRIxBITS __PRIxBIT + +#define __SHIFTOUT(__x, __mask) (((__x) & (__mask)) / __LOWEST_SET_BIT(__mask)) +#define __SHIFTIN(__x, __mask) ((__x) * __LOWEST_SET_BIT(__mask)) +#define __SHIFTOUT_MASK(__mask) __SHIFTOUT((__mask), (__mask)) + +/* + * Only to be used in other headers that are included from both c or c++ + * NOT to be used in code. + */ +#ifdef __cplusplus +#define __CAST(__dt, __st) static_cast<__dt>(__st) +#else +#define __CAST(__dt, __st) ((__dt)(__st)) +#endif + +#endif /* !_SYS_CDEFS_H_ */ diff --git a/lib/Makefile b/lib/Makefile index 18681aa78..24204c21e 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -1,7 +1,7 @@ .include SUBDIR= csu libc libcurses libdriver libnetdriver libend libedit libm libsys \ - libtimers libutil + libtimers libutil libbz2 libl .if ${COMPILER_TYPE} == "ack" SUBDIR+= ack/libd ack/libe ack/libfp ack/liby diff --git a/lib/libbz2/Makefile b/lib/libbz2/Makefile new file mode 100644 index 000000000..ec9c188a4 --- /dev/null +++ b/lib/libbz2/Makefile @@ -0,0 +1,14 @@ +.include + +LIB= bz2 +BZ2DIR= ${MINIXSRCDIR}/commands/bzip2 +.PATH: ${BZ2DIR} + +SRCS= bzlib.c blocksort.c compress.c crctable.c decompress.c \ + huffman.c randtable.c +CPPFLAGS+= -I ${BZ2DIR} +CPPFLAGS+= -O -D_MINIX -D_POSIX_SOURCE +INCS= bzlib.h +INCSDIR= /usr/include + +.include diff --git a/lib/libc/other/syslog.c b/lib/libc/other/syslog.c index caf2120e4..8db82df3c 100644 --- a/lib/libc/other/syslog.c +++ b/lib/libc/other/syslog.c @@ -139,7 +139,7 @@ void syslog(int lprty, const char *msg,...) len += sprintf(buff + len, "[%d]: ", LogPid); } va_start(ap, msg); - len += vsprintf(buff + len, msg, ap); + len += vsnprintf(buff + len, sizeof(buff) - len, msg, ap); va_end(ap); rc = write(nfd, buff, len); if ((rc != len && LogFlags & LOG_CONS) || LogFlags & LOG_PERROR) { diff --git a/lib/libc/stdtime/Makefile.inc b/lib/libc/stdtime/Makefile.inc index c994980c7..518de68f9 100644 --- a/lib/libc/stdtime/Makefile.inc +++ b/lib/libc/stdtime/Makefile.inc @@ -1,12 +1,6 @@ # stdtime sources .PATH: ${.CURDIR}/stdtime -Z=${.CURDIR}/../../commands/zoneinfo - -CPPFLAGS.asctime.c+=-I$Z -CPPFLAGS.localtime.c+=-I$Z -CPPFLAGS.strftime.c+=-I$Z - SRCS+= \ ftime.c \ asctime.c \ diff --git a/man/man1/date.1 b/lib/libc/stdtime/date.1 similarity index 100% rename from man/man1/date.1 rename to lib/libc/stdtime/date.1 diff --git a/commands/zoneinfo/date.c b/lib/libc/stdtime/date.c similarity index 100% rename from commands/zoneinfo/date.c rename to lib/libc/stdtime/date.c diff --git a/commands/zoneinfo/difftime.c b/lib/libc/stdtime/difftime.c similarity index 100% rename from commands/zoneinfo/difftime.c rename to lib/libc/stdtime/difftime.c diff --git a/commands/zoneinfo/ialloc.c b/lib/libc/stdtime/ialloc.c similarity index 100% rename from commands/zoneinfo/ialloc.c rename to lib/libc/stdtime/ialloc.c diff --git a/commands/zoneinfo/logwtmp.c b/lib/libc/stdtime/logwtmp.c similarity index 100% rename from commands/zoneinfo/logwtmp.c rename to lib/libc/stdtime/logwtmp.c diff --git a/commands/zoneinfo/private.h b/lib/libc/stdtime/private.h similarity index 100% rename from commands/zoneinfo/private.h rename to lib/libc/stdtime/private.h diff --git a/commands/zoneinfo/scheck.c b/lib/libc/stdtime/scheck.c similarity index 100% rename from commands/zoneinfo/scheck.c rename to lib/libc/stdtime/scheck.c diff --git a/commands/zoneinfo/tzfile.h b/lib/libc/stdtime/tzfile.h similarity index 100% rename from commands/zoneinfo/tzfile.h rename to lib/libc/stdtime/tzfile.h diff --git a/man/man8/zdump.8 b/lib/libc/stdtime/zdump.8 similarity index 100% rename from man/man8/zdump.8 rename to lib/libc/stdtime/zdump.8 diff --git a/commands/zoneinfo/zdump.c b/lib/libc/stdtime/zdump.c similarity index 100% rename from commands/zoneinfo/zdump.c rename to lib/libc/stdtime/zdump.c diff --git a/man/man8/zic.8 b/lib/libc/stdtime/zic.8 similarity index 100% rename from man/man8/zic.8 rename to lib/libc/stdtime/zic.8 diff --git a/commands/zoneinfo/zic.c b/lib/libc/stdtime/zic.c similarity index 100% rename from commands/zoneinfo/zic.c rename to lib/libc/stdtime/zic.c diff --git a/lib/libl/Makefile b/lib/libl/Makefile new file mode 100644 index 000000000..432850f0e --- /dev/null +++ b/lib/libl/Makefile @@ -0,0 +1,12 @@ +# $NetBSD: Makefile,v 1.13 2006/09/11 22:24:09 dbj Exp $ + +.include + +LIB= l +SRCS= libmain.c libyywrap.c + +LINKS= ${LIBDIR}/libl.a ${LIBDIR}/libfl.a + +.PATH: ${MINIXSRCDIR}/commands/lex + +.include diff --git a/man/man1/Makefile b/man/man1/Makefile index 90843e3b7..27374edf7 100644 --- a/man/man1/Makefile +++ b/man/man1/Makefile @@ -1,13 +1,13 @@ MAN= acd.1 anm.1 ar.1 ash.1 asize.1 at.1 banner.1 basename.1 \ - bsfilt.1 bzdiff.1 bzgrep.1 bzip2.1 bzmore.1 cal.1 \ + bsfilt.1 cal.1 \ calendar.1 cat.1 cawf.1 cc.1 cdiff.1 cgrep.1 chgrp.1 \ chmem.1 chmod.1 cksum.1 clear.1 cmp.1 comm.1 compress.1 \ - cp.1 crc.1 crontab.1 ctags.1 cut.1 date.1 dd.1 dev2name.1 \ + cp.1 crc.1 crontab.1 ctags.1 cut.1 dd.1 dev2name.1 \ df.1 dhrystone.1 diff.1 dosdir.1 dosread.1 doswrite.1 du.1 \ dumpcore.1 easypack.1 echo.1 ed.1 eject.1 elvis.1 elvrec.1 \ env.1 expand.1 expr.1 factor.1 fgrep.1 file.1 find.1 \ - finger.1 flex.1 flexdoc.1 fmt.1 fold.1 format.1 fortune.1 \ - fsck.1 ftp.1 grep.1 head.1 host.1 hostaddr.1 id.1 ifdef.1 \ + finger.1 flexdoc.1 fmt.1 fold.1 format.1 fortune.1 \ + fsck.1 grep.1 head.1 host.1 hostaddr.1 id.1 ifdef.1 \ install.1 isodir.1 isoinfo.1 isoread.1 join.1 kill.1 \ last.1 leave.1 loadfont.1 loadkeys.1 logger.1 login.1 \ look.1 lp.1 ls.1 lspci.1 M.1 mail.1 make.1 makewhatis.1 \ @@ -23,7 +23,7 @@ MAN= acd.1 anm.1 ar.1 ash.1 asize.1 at.1 banner.1 basename.1 \ term.1 termcap.1 tget.1 time.1 top.1 touch.1 tr.1 true.1 \ truncate.1 tsort.1 tty.1 umount.1 uname.1 unexpand.1 uniq.1 \ urlget.1 uud.1 uue.1 vol.1 wc.1 whatis.1 whereis.1 which.1 \ - who.1 whoami.1 write.1 xargs.1 yacc.1 yap.1 yes.1 + who.1 whoami.1 write.1 xargs.1 yap.1 yes.1 .include .include diff --git a/man/man1/flex.1 b/man/man1/flex.1 deleted file mode 100644 index 5556f9ac1..000000000 --- a/man/man1/flex.1 +++ /dev/null @@ -1,780 +0,0 @@ -.TH FLEX 1 "26 May 1990" "Version 2.3" -.SH NAME -flex, lex - fast lexical analyzer generator -.SH SYNOPSIS -.B flex -.B [-bcdfinpstvFILT8 -C[efmF] -Sskeleton] -.I [filename ...] -.SH DESCRIPTION -.I flex -is a tool for generating -.I scanners: -programs which recognized lexical patterns in text. -.I flex -reads -the given input files, or its standard input if no file names are given, -for a description of a scanner to generate. The description is in -the form of pairs -of regular expressions and C code, called -.I rules. flex -generates as output a C source file, -.B lex.yy.c, -which defines a routine -.B yylex(). -This file is compiled and linked with the -.B -lfl -library to produce an executable. When the executable is run, -it analyzes its input for occurrences -of the regular expressions. Whenever it finds one, it executes -the corresponding C code. -.LP -For full documentation, see -.B flexdoc(1). -This manual entry is intended for use as a quick reference. -.SH OPTIONS -.I flex -has the following options: -.TP -.B -b -Generate backtracking information to -.I lex.backtrack. -This is a list of scanner states which require backtracking -and the input characters on which they do so. By adding rules one -can remove backtracking states. If all backtracking states -are eliminated and -.B -f -or -.B -F -is used, the generated scanner will run faster. -.TP -.B -c -is a do-nothing, deprecated option included for POSIX compliance. -.IP -.B NOTE: -in previous releases of -.I flex -.B -c -specified table-compression options. This functionality is -now given by the -.B -C -flag. To ease the the impact of this change, when -.I flex -encounters -.B -c, -it currently issues a warning message and assumes that -.B -C -was desired instead. In the future this "promotion" of -.B -c -to -.B -C -will go away in the name of full POSIX compliance (unless -the POSIX meaning is removed first). -.TP -.B -d -makes the generated scanner run in -.I debug -mode. Whenever a pattern is recognized and the global -.B yy_flex_debug -is non-zero (which is the default), the scanner will -write to -.I stderr -a line of the form: -.nf - - --accepting rule at line 53 ("the matched text") - -.fi -The line number refers to the location of the rule in the file -defining the scanner (i.e., the file that was fed to flex). Messages -are also generated when the scanner backtracks, accepts the -default rule, reaches the end of its input buffer (or encounters -a NUL; the two look the same as far as the scanner's concerned), -or reaches an end-of-file. -.TP -.B -f -specifies (take your pick) -.I full table -or -.I fast scanner. -No table compression is done. The result is large but fast. -This option is equivalent to -.B -Cf -(see below). -.TP -.B -i -instructs -.I flex -to generate a -.I case-insensitive -scanner. The case of letters given in the -.I flex -input patterns will -be ignored, and tokens in the input will be matched regardless of case. The -matched text given in -.I yytext -will have the preserved case (i.e., it will not be folded). -.TP -.B -n -is another do-nothing, deprecated option included only for -POSIX compliance. -.TP -.B -p -generates a performance report to stderr. The report -consists of comments regarding features of the -.I flex -input file which will cause a loss of performance in the resulting scanner. -.TP -.B -s -causes the -.I default rule -(that unmatched scanner input is echoed to -.I stdout) -to be suppressed. If the scanner encounters input that does not -match any of its rules, it aborts with an error. -.TP -.B -t -instructs -.I flex -to write the scanner it generates to standard output instead -of -.B lex.yy.c. -.TP -.B -v -specifies that -.I flex -should write to -.I stderr -a summary of statistics regarding the scanner it generates. -.TP -.B -F -specifies that the -.I fast -scanner table representation should be used. This representation is -about as fast as the full table representation -.RB ( \-f ), -and for some sets of patterns will be considerably smaller (and for -others, larger). See -.B flexdoc(1) -for details. -.IP -This option is equivalent to -.B -CF -(see below). -.TP -.B -I -instructs -.I flex -to generate an -.I interactive -scanner, that is, a scanner which stops immediately rather than -looking ahead if it knows -that the currently scanned text cannot be part of a longer rule's match. -Again, see -.B flexdoc(1) -for details. -.IP -Note, -.B -I -cannot be used in conjunction with -.I full -or -.I fast tables, -i.e., the -.B -f, -F, -Cf, -or -.B -CF -flags. -.TP -.B -L -instructs -.I flex -not to generate -.B #line -directives in -.B lex.yy.c. -The default is to generate such directives so error -messages in the actions will be correctly -located with respect to the original -.I flex -input file, and not to -the fairly meaningless line numbers of -.B lex.yy.c. -.TP -.B -T -makes -.I flex -run in -.I trace -mode. It will generate a lot of messages to -.I stdout -concerning -the form of the input and the resultant non-deterministic and deterministic -finite automata. This option is mostly for use in maintaining -.I flex. -.TP -.B -8 -instructs -.I flex -to generate an 8-bit scanner. -On some sites, this is the default. On others, the default -is 7-bit characters. To see which is the case, check the verbose -.B (-v) -output for "equivalence classes created". If the denominator of -the number shown is 128, then by default -.I flex -is generating 7-bit characters. If it is 256, then the default is -8-bit characters. -.TP -.B -C[efmF] -controls the degree of table compression. -.IP -.B -Ce -directs -.I flex -to construct -.I equivalence classes, -i.e., sets of characters -which have identical lexical properties. -Equivalence classes usually give -dramatic reductions in the final table/object file sizes (typically -a factor of 2-5) and are pretty cheap performance-wise (one array -look-up per character scanned). -.IP -.B -Cf -specifies that the -.I full -scanner tables should be generated - -.I flex -should not compress the -tables by taking advantages of similar transition functions for -different states. -.IP -.B -CF -specifies that the alternate fast scanner representation (described in -.B flexdoc(1)) -should be used. -.IP -.B -Cm -directs -.I flex -to construct -.I meta-equivalence classes, -which are sets of equivalence classes (or characters, if equivalence -classes are not being used) that are commonly used together. Meta-equivalence -classes are often a big win when using compressed tables, but they -have a moderate performance impact (one or two "if" tests and one -array look-up per character scanned). -.IP -A lone -.B -C -specifies that the scanner tables should be compressed but neither -equivalence classes nor meta-equivalence classes should be used. -.IP -The options -.B -Cf -or -.B -CF -and -.B -Cm -do not make sense together - there is no opportunity for meta-equivalence -classes if the table is not being compressed. Otherwise the options -may be freely mixed. -.IP -The default setting is -.B -Cem, -which specifies that -.I flex -should generate equivalence classes -and meta-equivalence classes. This setting provides the highest -degree of table compression. You can trade off -faster-executing scanners at the cost of larger tables with -the following generally being true: -.nf - - slowest & smallest - -Cem - -Cm - -Ce - -C - -C{f,F}e - -C{f,F} - fastest & largest - -.fi -.IP -.B -C -options are not cumulative; whenever the flag is encountered, the -previous -C settings are forgotten. -.TP -.B -Sskeleton_file -overrides the default skeleton file from which -.I flex -constructs its scanners. You'll never need this option unless you are doing -.I flex -maintenance or development. -.SH SUMMARY OF FLEX REGULAR EXPRESSIONS -The patterns in the input are written using an extended set of regular -expressions. These are: -.nf - - x match the character 'x' - . any character except newline - [xyz] a "character class"; in this case, the pattern - matches either an 'x', a 'y', or a 'z' - [abj-oZ] a "character class" with a range in it; matches - an 'a', a 'b', any letter from 'j' through 'o', - or a 'Z' - [^A-Z] a "negated character class", i.e., any character - but those in the class. In this case, any - character EXCEPT an uppercase letter. - [^A-Z\\n] any character EXCEPT an uppercase letter or - a newline - r* zero or more r's, where r is any regular expression - r+ one or more r's - r? zero or one r's (that is, "an optional r") - r{2,5} anywhere from two to five r's - r{2,} two or more r's - r{4} exactly 4 r's - {name} the expansion of the "name" definition - (see above) - "[xyz]\\"foo" - the literal string: [xyz]"foo - \\X if X is an 'a', 'b', 'f', 'n', 'r', 't', or 'v', - then the ANSI-C interpretation of \\x. - Otherwise, a literal 'X' (used to escape - operators such as '*') - \\123 the character with octal value 123 - \\x2a the character with hexadecimal value 2a - (r) match an r; parentheses are used to override - precedence (see below) - - - rs the regular expression r followed by the - regular expression s; called "concatenation" - - - r|s either an r or an s - - - r/s an r but only if it is followed by an s. The - s is not part of the matched text. This type - of pattern is called as "trailing context". - ^r an r, but only at the beginning of a line - r$ an r, but only at the end of a line. Equivalent - to "r/\\n". - - - r an r, but only in start condition s (see - below for discussion of start conditions) - r - same, but in any of start conditions s1, - s2, or s3 - - - <> an end-of-file - <> - an end-of-file when in start condition s1 or s2 - -.fi -The regular expressions listed above are grouped according to -precedence, from highest precedence at the top to lowest at the bottom. -Those grouped together have equal precedence. -.LP -Some notes on patterns: -.IP - -Negated character classes -.I match newlines -unless "\\n" (or an equivalent escape sequence) is one of the -characters explicitly present in the negated character class -(e.g., "[^A-Z\\n]"). -.IP - -A rule can have at most one instance of trailing context (the '/' operator -or the '$' operator). The start condition, '^', and "<>" patterns -can only occur at the beginning of a pattern, and, as well as with '/' and '$', -cannot be grouped inside parentheses. The following are all illegal: -.nf - - foo/bar$ - foo|(bar$) - foo|^bar - foobar - -.fi -.SH SUMMARY OF SPECIAL ACTIONS -In addition to arbitrary C code, the following can appear in actions: -.IP - -.B ECHO -copies yytext to the scanner's output. -.IP - -.B BEGIN -followed by the name of a start condition places the scanner in the -corresponding start condition. -.IP - -.B REJECT -directs the scanner to proceed on to the "second best" rule which matched the -input (or a prefix of the input). -.B yytext -and -.B yyleng -are set up appropriately. Note that -.B REJECT -is a particularly expensive feature in terms scanner performance; -if it is used in -.I any -of the scanner's actions it will slow down -.I all -of the scanner's matching. Furthermore, -.B REJECT -cannot be used with the -.I -f -or -.I -F -options. -.IP -Note also that unlike the other special actions, -.B REJECT -is a -.I branch; -code immediately following it in the action will -.I not -be executed. -.IP - -.B yymore() -tells the scanner that the next time it matches a rule, the corresponding -token should be -.I appended -onto the current value of -.B yytext -rather than replacing it. -.IP - -.B yyless(n) -returns all but the first -.I n -characters of the current token back to the input stream, where they -will be rescanned when the scanner looks for the next match. -.B yytext -and -.B yyleng -are adjusted appropriately (e.g., -.B yyleng -will now be equal to -.I n -). -.IP - -.B unput(c) -puts the character -.I c -back onto the input stream. It will be the next character scanned. -.IP - -.B input() -reads the next character from the input stream (this routine is called -.B yyinput() -if the scanner is compiled using -.B C++). -.IP - -.B yyterminate() -can be used in lieu of a return statement in an action. It terminates -the scanner and returns a 0 to the scanner's caller, indicating "all done". -.IP -By default, -.B yyterminate() -is also called when an end-of-file is encountered. It is a macro and -may be redefined. -.IP - -.B YY_NEW_FILE -is an action available only in <> rules. It means "Okay, I've -set up a new input file, continue scanning". -.IP - -.B yy_create_buffer( file, size ) -takes a -.I FILE -pointer and an integer -.I size. -It returns a YY_BUFFER_STATE -handle to a new input buffer large enough to accomodate -.I size -characters and associated with the given file. When in doubt, use -.B YY_BUF_SIZE -for the size. -.IP - -.B yy_switch_to_buffer( new_buffer ) -switches the scanner's processing to scan for tokens from -the given buffer, which must be a YY_BUFFER_STATE. -.IP - -.B yy_delete_buffer( buffer ) -deletes the given buffer. -.SH VALUES AVAILABLE TO THE USER -.IP - -.B char *yytext -holds the text of the current token. It may not be modified. -.IP - -.B int yyleng -holds the length of the current token. It may not be modified. -.IP - -.B FILE *yyin -is the file which by default -.I flex -reads from. It may be redefined but doing so only makes sense before -scanning begins. Changing it in the middle of scanning will have -unexpected results since -.I flex -buffers its input. Once scanning terminates because an end-of-file -has been seen, -.B -void yyrestart( FILE *new_file ) -may be called to point -.I yyin -at the new input file. -.IP - -.B FILE *yyout -is the file to which -.B ECHO -actions are done. It can be reassigned by the user. -.IP - -.B YY_CURRENT_BUFFER -returns a -.B YY_BUFFER_STATE -handle to the current buffer. -.SH MACROS THE USER CAN REDEFINE -.IP - -.B YY_DECL -controls how the scanning routine is declared. -By default, it is "int yylex()", or, if prototypes are being -used, "int yylex(void)". This definition may be changed by redefining -the "YY_DECL" macro. Note that -if you give arguments to the scanning routine using a -K&R-style/non-prototyped function declaration, you must terminate -the definition with a semi-colon (;). -.IP - -The nature of how the scanner -gets its input can be controlled by redefining the -.B YY_INPUT -macro. -YY_INPUT's calling sequence is "YY_INPUT(buf,result,max_size)". Its -action is to place up to -.I max_size -characters in the character array -.I buf -and return in the integer variable -.I result -either the -number of characters read or the constant YY_NULL (0 on Unix systems) -to indicate EOF. The default YY_INPUT reads from the -global file-pointer "yyin". -A sample redefinition of YY_INPUT (in the definitions -section of the input file): -.nf - - %{ - #undef YY_INPUT - #define YY_INPUT(buf,result,max_size) \\ - { \\ - int c = getchar(); \\ - result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \\ - } - %} - -.fi -.IP - -When the scanner receives an end-of-file indication from YY_INPUT, -it then checks the -.B yywrap() -function. If -.B yywrap() -returns false (zero), then it is assumed that the -function has gone ahead and set up -.I yyin -to point to another input file, and scanning continues. If it returns -true (non-zero), then the scanner terminates, returning 0 to its -caller. -.IP -The default -.B yywrap() -always returns 1. Presently, to redefine it you must first -"#undef yywrap", as it is currently implemented as a macro. It is -likely that -.B yywrap() -will soon be defined to be a function rather than a macro. -.IP - -YY_USER_ACTION -can be redefined to provide an action -which is always executed prior to the matched rule's action. -.IP - -The macro -.B YY_USER_INIT -may be redefined to provide an action which is always executed before -the first scan. -.IP - -In the generated scanner, the actions are all gathered in one large -switch statement and separated using -.B YY_BREAK, -which may be redefined. By default, it is simply a "break", to separate -each rule's action from the following rule's. -.SH FILES -.TP -.I flex.skel -skeleton scanner. -.TP -.I lex.yy.c -generated scanner (called -.I lexyy.c -on some systems). -.TP -.I lex.backtrack -backtracking information for -.B -b -flag (called -.I lex.bck -on some systems). -.TP -.B -lfl -library with which to link the scanners. -.SH "SEE ALSO" -.LP -flexdoc(1), lex(1), yacc(1), sed(1), awk(1x). -.LP -M. E. Lesk and E. Schmidt, -.I LEX - Lexical Analyzer Generator -.SH DIAGNOSTICS -.I reject_used_but_not_detected undefined -or -.LP -.I yymore_used_but_not_detected undefined - -These errors can occur at compile time. They indicate that the -scanner uses -.B REJECT -or -.B yymore() -but that -.I flex -failed to notice the fact, meaning that -.I flex -scanned the first two sections looking for occurrences of these actions -and failed to find any, but somehow you snuck some in (via a #include -file, for example). Make an explicit reference to the action in your -.I flex -input file. (Note that previously -.I flex -supported a -.B %used/%unused -mechanism for dealing with this problem; this feature is still supported -but now deprecated, and will go away soon unless the author hears from -people who can argue compellingly that they need it.) -.LP -.I flex scanner jammed - -a scanner compiled with -.B -s -has encountered an input string which wasn't matched by -any of its rules. -.LP -.I flex input buffer overflowed - -a scanner rule matched a string long enough to overflow the -scanner's internal input buffer (16K bytes - controlled by -.B YY_BUF_MAX -in "flex.skel"). -.LP -.I scanner requires -8 flag - -Your scanner specification includes recognizing 8-bit characters and -you did not specify the -8 flag (and your site has not installed flex -with -8 as the default). -.LP -.I -fatal flex scanner internal error--end of buffer missed - -This can occur in an scanner which is reentered after a long-jump -has jumped out (or over) the scanner's activation frame. Before -reentering the scanner, use: -.nf - - yyrestart( yyin ); - -.fi -.LP -.I too many %t classes! - -You managed to put every single character into its own %t class. -.I flex -requires that at least one of the classes share characters. -.SH AUTHOR -Vern Paxson, with the help of many ideas and much inspiration from -Van Jacobson. Original version by Jef Poskanzer. -.LP -See flexdoc(1) for additional credits and the address to send comments to. -.SH DEFICIENCIES / BUGS -.LP -Some trailing context -patterns cannot be properly matched and generate -warning messages ("Dangerous trailing context"). These are -patterns where the ending of the -first part of the rule matches the beginning of the second -part, such as "zx*/xy*", where the 'x*' matches the 'x' at -the beginning of the trailing context. (Note that the POSIX draft -states that the text matched by such patterns is undefined.) -.LP -For some trailing context rules, parts which are actually fixed-length are -not recognized as such, leading to the abovementioned performance loss. -In particular, parts using '|' or {n} (such as "foo{3}") are always -considered variable-length. -.LP -Combining trailing context with the special '|' action can result in -.I fixed -trailing context being turned into the more expensive -.I variable -trailing context. For example, this happens in the following example: -.nf - - %% - abc | - xyz/def - -.fi -.LP -Use of unput() invalidates yytext and yyleng. -.LP -Use of unput() to push back more text than was matched can -result in the pushed-back text matching a beginning-of-line ('^') -rule even though it didn't come at the beginning of the line -(though this is rare!). -.LP -Pattern-matching of NUL's is substantially slower than matching other -characters. -.LP -.I flex -does not generate correct #line directives for code internal -to the scanner; thus, bugs in -.I flex.skel -yield bogus line numbers. -.LP -Due to both buffering of input and read-ahead, you cannot intermix -calls to routines, such as, for example, -.B getchar(), -with -.I flex -rules and expect it to work. Call -.B input() -instead. -.LP -The total table entries listed by the -.B -v -flag excludes the number of table entries needed to determine -what rule has been matched. The number of entries is equal -to the number of DFA states if the scanner does not use -.B REJECT, -and somewhat greater than the number of states if it does. -.LP -.B REJECT -cannot be used with the -.I -f -or -.I -F -options. -.LP -Some of the macros, such as -.B yywrap(), -may in the future become functions which live in the -.B -lfl -library. This will doubtless break a lot of code, but may be -required for POSIX-compliance. -.LP -The -.I flex -internal algorithms need documentation. -.\" ref. to awk(9) man page corrected -- ASW 2005-01-15 diff --git a/man/man1/ftp.1 b/man/man1/ftp.1 deleted file mode 100644 index e47cc0787..000000000 --- a/man/man1/ftp.1 +++ /dev/null @@ -1,150 +0,0 @@ -.TH FTP 1 -.SH NAME -ftp \- a File Transfer Protocol client for Minix -.SH SYNOPSIS -.B ftp -.RI [ server_name ] -.SH DESCRIPTION -.B Ftp -is a File Transfer Protocol client for Minix written by Michael Temari. -.P -There are no command line options for -.B ftp -except for the optional server name, which may be either a numeric IP address -or a domain name resolvable by DNS. -.P -If a server name is specified a connection attempt will be made, and you -will be prompted for a user name and password by the remote system. -Following the login (or immediately, if no server name was specified), the -.br -.B ftp> -.br -prompt is displayed. The following commands are accepted at the prompt: -.P -Command: Description -.br -! Escape to a shell -.br -append Append a file to remote host -.br -ascii Set file transfer type to ascii -.br -binary Set file transfer type to binary -.br -block Set file transfer mode to block -.br -bye Close connection and exit -.br -cd Change directory on remote host -.br -close Close connection -.br -clone Clone a file -.br -del Remove file on remote host -.br -dir Display long form remote host directory listing -.br -exit Close connection and exit -.br -get Retrieve a file from remote host -.br -help Display this text -.br -lcd Change directory on local host -.br -ldir Display long form local host directory listing -.br -lls Display local host directory listing -.br -lmkdir Create directory on local host -.br -lpwd Display current directory on local host -.br -lrmdir Remove directory on local host -.br -ls Display remote host directory listing -.br -mget Retrieve multiple files from remote host -.br -mkdir Create directory on remote host -.br -mod Get file modification time -.br -mput Send multiple files to remote host -.br -noop Send the ftp NOOP command -.br -open Open connection to remote host -.br -pass Enter remote user password -.br -passive Toggle passive mode -.br -put Send a file to remote host -.br -putu Send a file to remote host(unique) -.br -pwd Display current directory on remote host -.br -quit Close connection and exit -.br -quote Send raw ftp command to remote host -.br -reget Restart a partial file retrieve from remote host -.br -remotehelp Display ftp commands implemented on remote host -.br -reput Restart a partial file send to remote host -.br -rm Remove file on remote host -.br -rmdir Remove directory on remote host -.br -site Send a site specific command -.br -size Get file size information -.br -status Get connection/file status information -.br -stream Set file transfer mode to stream -.br -system Get remote system type information -.br -user Enter remote user information -.br -ver Display client version information - -.SH "SEE ALSO" -.BR ftpd (8) -.br -.BR ftpget (1) -.br -.SH NOTES -The FTP protocol passes unencrypted usernames and passwords to clients, -so they are potentially exposed to evildoers with network sniffers. So be -wary of using this to exchange files between your own accounts. Obviously -if you have a root account on another system and the remote system will -accept a login as root this is extremely dangerous. (Many ftp servers will -not allow a connection by root). -.P -Text-mode (ASCII) transfers are the default mode, be sure to enter the -"binary" command if you are downloading a program file or a compressed -archive, in fact anything other than a text file from a machine with a -different text-file format than Minix uses. -.P -If you are behind a firewall you probably need to use passive mode to -successfully transfer files. - -.SH BUGS -None are known, but there may be some unknown ones. Version 1.00 corrects -a bug in previous versions that would append a \\r (0xd) character to file -names on the destination when an mget transfer was used in binary mode. - -.SH AUTHOR -The Minix httpd server was created by and is maintained by Michael Temari -. The earliest version was released in 1992, for use -with Michael's TNet networking extensions for Minix 1.5. -.P -Man page compiled by Al Woodhull -.\" updated 2003-12-13 diff --git a/man/man1/yacc.1 b/man/man1/yacc.1 deleted file mode 100644 index ad3003ab6..000000000 --- a/man/man1/yacc.1 +++ /dev/null @@ -1,111 +0,0 @@ -.\" %W% %R% (Berkeley) %E% -.\" -.TH YACC 1 "July 15, 1990" -.UC 6 -.SH NAME -yacc \- an LALR(1) parser generator -.SH SYNOPSIS -.B yacc [ -dlrtv ] [ -b -.I file_prefix -.B ] [ -p -.I symbol_prefix -.B ] -.I filename -.SH DESCRIPTION -.I Yacc -reads the grammar specification in the file -.I filename -and generates an LR(1) parser for it. -The parsers consist of a set of LALR(1) parsing tables and a driver routine -written in the C programming language. -.I Yacc -normally writes the parse tables and the driver routine to the file -.IR y.tab.c. -.PP -The following options are available: -.RS -.TP -\fB-b \fIfile_prefix\fR -The -.B -b -option changes the prefix prepended to the output file names to -the string denoted by -.IR file_prefix. -The default prefix is the character -.IR y. -.TP -.B -d -The \fB-d\fR option causes the header file -.IR y.tab.h -to be written. -.TP -.B -l -If the -.B -l -option is not specified, -.I yacc -will insert #line directives in the generated code. -The #line directives let the C compiler relate errors in the -generated code to the user's original code. -If the \fB-l\fR option is specified, -.I yacc -will not insert the #line directives. -\&#line directives specified by the user will be retained. -.TP -\fB-p \fIsymbol_prefix\fR -The -.B -p -option changes the prefix prepended to yacc-generated symbols to -the string denoted by -.IR symbol_prefix. -The default prefix is the string -.IR yy. -.TP -.B -r -The -.B -r -option causes -.I yacc -to produce separate files for code and tables. The code file -is named -.IR y.code.c, -and the tables file is named -.IR y.tab.c. -.TP -.B -t -The -.B -t -option changes the preprocessor directives generated by -.I yacc -so that debugging statements will be incorporated in the compiled code. -.TP -.B -v -The -.B -v -option causes a human-readable description of the generated parser to -be written to the file -.IR y.output. -.RE -.PP -If the environment variable TMPDIR is set, the string denoted by -TMPDIR will be used as the name of the directory where the temporary -files are created. -.SH FILES -.IR y.code.c -.br -.IR y.tab.c -.br -.IR y.tab.h -.br -.IR y.output -.br -.IR /tmp/yacc.aXXXXXX -.br -.IR /tmp/yacc.tXXXXXX -.br -.IR /tmp/yacc.uXXXXXX -.SH DIAGNOSTICS -If there are rules that are never reduced, the number of such rules is -reported on standard error. -If there are any LALR(1) conflicts, the number of conflicts is reported -on standard error. diff --git a/man/man8/Makefile b/man/man8/Makefile index 95e5c3c7b..0664ab855 100644 --- a/man/man8/Makefile +++ b/man/man8/Makefile @@ -9,7 +9,7 @@ MAN= add_route.8 adduser.8 backup.8 badblocks.8 boot.8 \ rdate.8 readclock.8 reboot.8 repartition.8 rlogind.8 \ rshd.8 savemixer.8 screendump.8 serial-ip.8 service.8 \ setup.8 shutdown.8 slip.8 srccrc.8 sync.8 syslogd.8 tcpd.8 \ - tzselect.8 update.8 usage.8 vmixctl.8 zdump.8 zic.8 + update.8 usage.8 vmixctl.8 .include .include diff --git a/man/man8/tzselect.8 b/man/man8/tzselect.8 deleted file mode 100644 index f839ed828..000000000 --- a/man/man8/tzselect.8 +++ /dev/null @@ -1,41 +0,0 @@ -.TH TZSELECT 8 -.SH NAME -tzselect \- select a time zone -.SH SYNOPSIS -.B tzselect -.SH DESCRIPTION -The -.B tzselect -program asks the user for information about the current location, -and outputs the resulting time zone description to standard output. -The output is suitable as a value for the TZ environment variable. -.PP -All interaction with the user is done via standard input and standard error. -.SH "ENVIRONMENT VARIABLES" -.TP -\f3AWK\fP -Name of a Posix-compliant -.I awk -program (default: -.BR awk ). -.TP -\f3TZDIR\fP -Name of the directory containing time zone data files (default: -.BR /usr/share/zoneinfo ). -.SH FILES -.TP -\f2TZDIR\fP\f3/iso3166.tab\fP -Table of ISO 3166 2-letter country codes and country names. -.TP -\f2TZDIR\fP\f3/zone.tab\fP -Table of country codes, latitude and longitude, TZ values, and -descriptive comments. -.TP -\f2TZDIR\fP\f3/\fP\f2TZ\fP -Time zone data file for time zone \f2TZ\fP. -.SH "EXIT STATUS" -The exit status is zero if a time zone was successfully obtained from the user, -nonzero otherwise. -.SH "SEE ALSO" -newctime(3), tzfile(5), zdump(8), zic(8) -.\" @(#)tzselect.8 1.3 diff --git a/share/Makefile b/share/Makefile new file mode 100644 index 000000000..9b105c7c0 --- /dev/null +++ b/share/Makefile @@ -0,0 +1,5 @@ +.include + +SUBDIR= zoneinfo + +.include diff --git a/share/zoneinfo/Makefile b/share/zoneinfo/Makefile new file mode 100644 index 000000000..7e676f171 --- /dev/null +++ b/share/zoneinfo/Makefile @@ -0,0 +1,112 @@ +# @(#)Makefile 7.109 + +.include + +# Change the line below for your time zone (after finding the zone you want in +# the time zone files, or adding it to a time zone file). +# Alternately, if you discover you've got the wrong time zone, you can just +# zic -l rightzone +# to correct things. +# Use the command +# make zonenames +# to get a list of the values you can use for LOCALTIME. + +LOCALTIME= GMT + +# If you want something other than Eastern United States time as a template +# for handling POSIX-style time zone environment variables, +# change the line below (after finding the zone you want in the +# time zone files, or adding it to a time zone file). +# (When a POSIX-style environment variable is handled, the rules in the +# template file are used to determine "spring forward" and "fall back" days and +# times; the environment variable itself specifies UTC offsets of standard and +# summer time.) +# Alternately, if you discover you've got the wrong time zone, you can just +# zic -p rightzone +# to correct things. +# Use the command +# make zonenames +# to get a list of the values you can use for POSIXRULES. +# If you want POSIX compatibility, use "America/New_York". + +POSIXRULES= America/New_York + +# Use an absolute path name for TZDIR unless you're just testing the software. + +TZDIR= ${DESTDIR}/usr/share/zoneinfo + +# If you always want time values interpreted as "seconds since the epoch +# (not counting leap seconds)", use +# REDO= posix_only +# below. If you always want right time values interpreted as "seconds since +# the epoch" (counting leap seconds)", use +# REDO= right_only +# below. If you want both sets of data available, with leap seconds not +# counted normally, use +# REDO= posix_right +# below. If you want both sets of data available, with leap seconds counted +# normally, use +# REDO= right_posix +# below. + +REDO= posix_right + +# Since "." may not be in PATH... +YEARISTYPE= "${HOST_SH} ${.CURDIR}/yearistype.sh" + +YDATA= africa antarctica asia australasia \ + europe northamerica southamerica pacificnew etcetera factory \ + backward +NDATA= systemv +SDATA= solar87 solar88 solar89 +TDATA= $(YDATA) $(NDATA) $(SDATA) +TABDATA= iso3166.tab zone.tab +DATA= $(YDATA) $(NDATA) $(SDATA) leapseconds # yearistype.sh +USNO= usno1988 usno1989 + +.PHONY: posix_only +posix_only: ${TDATA} + ${_MKTARGET_CREATE} + cd ${.CURDIR} && \ + ${TOOL_ZIC} -y ${YEARISTYPE} -d ${TZDIR} -L /dev/null ${TDATA} + +.PHONY: right_only +right_only: leapseconds ${TDATA} + ${_MKTARGET_CREATE} + cd ${.CURDIR} && \ + ${TOOL_ZIC} -y ${YEARISTYPE} -d ${TZDDIR} -L leapseconds ${TDATA} + +# In earlier versions of this makefile, the other two directories were +# subdirectories of $(TZDIR). However, this led to configuration errors. +# For example, with posix_right under the earlier scheme, +# TZ='right/Australia/Adelaide' got you localtime with leap seconds, +# but gmtime without leap seconds, which led to problems with applications +# like sendmail that subtract gmtime from localtime. +# Therefore, the other two directories are now siblings of $(TZDIR). +# You must replace all of $(TZDIR) to switch from not using leap seconds +# to using them, or vice versa. +.PHONY: other_two +other_two: leapseconds ${TDATA} + ${_MKTARGET_CREATE} + cd ${.CURDIR} && \ + ${TOOL_ZIC} -y ${YEARISTYPE} -d ${TZDIR}-posix -L /dev/null ${TDATA} + cd ${.CURDIR} && \ + ${TOOL_ZIC} -y ${YEARISTYPE} -d ${TZDIR}-leaps -L leapseconds ${TDATA} + +.PHONY: posix_right +posix_right: posix_only other_two + +.PHONY: right_posix +right_posix: right_only other_two + +afterinstall: ${DATA} ${REDO} ${TABDATA} + ${_MKMSG_CREATE} ${POSIXRULES} + cd ${.CURDIR} && \ + ${TOOL_ZIC} -y ${YEARISTYPE} \ + -d ${TZDIR} -l ${LOCALTIME} -p ${POSIXRULES} + for f in ${TABDATA}; do \ + ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${NONBINMODE} \ + ${.CURDIR}/$$f ${DESTDIR}${TZDIR}; \ + done + +.include diff --git a/commands/zoneinfo/Makefile b/share/zoneinfo/Makefile.orig similarity index 100% rename from commands/zoneinfo/Makefile rename to share/zoneinfo/Makefile.orig diff --git a/commands/zoneinfo/README b/share/zoneinfo/README similarity index 100% rename from commands/zoneinfo/README rename to share/zoneinfo/README diff --git a/commands/zoneinfo/Theory b/share/zoneinfo/Theory similarity index 100% rename from commands/zoneinfo/Theory rename to share/zoneinfo/Theory diff --git a/commands/zoneinfo/africa b/share/zoneinfo/africa similarity index 100% rename from commands/zoneinfo/africa rename to share/zoneinfo/africa diff --git a/commands/zoneinfo/antarctica b/share/zoneinfo/antarctica similarity index 100% rename from commands/zoneinfo/antarctica rename to share/zoneinfo/antarctica diff --git a/commands/zoneinfo/asia b/share/zoneinfo/asia similarity index 100% rename from commands/zoneinfo/asia rename to share/zoneinfo/asia diff --git a/commands/zoneinfo/australasia b/share/zoneinfo/australasia similarity index 100% rename from commands/zoneinfo/australasia rename to share/zoneinfo/australasia diff --git a/commands/zoneinfo/backward b/share/zoneinfo/backward similarity index 100% rename from commands/zoneinfo/backward rename to share/zoneinfo/backward diff --git a/commands/zoneinfo/checktab.awk b/share/zoneinfo/checktab.awk similarity index 100% rename from commands/zoneinfo/checktab.awk rename to share/zoneinfo/checktab.awk diff --git a/commands/zoneinfo/etcetera b/share/zoneinfo/etcetera similarity index 100% rename from commands/zoneinfo/etcetera rename to share/zoneinfo/etcetera diff --git a/commands/zoneinfo/europe b/share/zoneinfo/europe similarity index 100% rename from commands/zoneinfo/europe rename to share/zoneinfo/europe diff --git a/commands/zoneinfo/factory b/share/zoneinfo/factory similarity index 100% rename from commands/zoneinfo/factory rename to share/zoneinfo/factory diff --git a/commands/zoneinfo/iso3166.tab b/share/zoneinfo/iso3166.tab similarity index 100% rename from commands/zoneinfo/iso3166.tab rename to share/zoneinfo/iso3166.tab diff --git a/commands/zoneinfo/itca.jpg b/share/zoneinfo/itca.jpg similarity index 100% rename from commands/zoneinfo/itca.jpg rename to share/zoneinfo/itca.jpg diff --git a/commands/zoneinfo/leapseconds b/share/zoneinfo/leapseconds similarity index 100% rename from commands/zoneinfo/leapseconds rename to share/zoneinfo/leapseconds diff --git a/commands/zoneinfo/northamerica b/share/zoneinfo/northamerica similarity index 100% rename from commands/zoneinfo/northamerica rename to share/zoneinfo/northamerica diff --git a/commands/zoneinfo/pacificnew b/share/zoneinfo/pacificnew similarity index 100% rename from commands/zoneinfo/pacificnew rename to share/zoneinfo/pacificnew diff --git a/commands/zoneinfo/solar87 b/share/zoneinfo/solar87 similarity index 100% rename from commands/zoneinfo/solar87 rename to share/zoneinfo/solar87 diff --git a/commands/zoneinfo/solar88 b/share/zoneinfo/solar88 similarity index 100% rename from commands/zoneinfo/solar88 rename to share/zoneinfo/solar88 diff --git a/commands/zoneinfo/solar89 b/share/zoneinfo/solar89 similarity index 100% rename from commands/zoneinfo/solar89 rename to share/zoneinfo/solar89 diff --git a/commands/zoneinfo/southamerica b/share/zoneinfo/southamerica similarity index 100% rename from commands/zoneinfo/southamerica rename to share/zoneinfo/southamerica diff --git a/commands/zoneinfo/systemv b/share/zoneinfo/systemv similarity index 100% rename from commands/zoneinfo/systemv rename to share/zoneinfo/systemv diff --git a/commands/zoneinfo/tz-art.htm b/share/zoneinfo/tz-art.htm similarity index 100% rename from commands/zoneinfo/tz-art.htm rename to share/zoneinfo/tz-art.htm diff --git a/commands/zoneinfo/tz-link.htm b/share/zoneinfo/tz-link.htm similarity index 100% rename from commands/zoneinfo/tz-link.htm rename to share/zoneinfo/tz-link.htm diff --git a/commands/zoneinfo/tzselect.ksh b/share/zoneinfo/tzselect.ksh similarity index 100% rename from commands/zoneinfo/tzselect.ksh rename to share/zoneinfo/tzselect.ksh diff --git a/commands/zoneinfo/usno1988 b/share/zoneinfo/usno1988 similarity index 100% rename from commands/zoneinfo/usno1988 rename to share/zoneinfo/usno1988 diff --git a/commands/zoneinfo/usno1989 b/share/zoneinfo/usno1989 similarity index 100% rename from commands/zoneinfo/usno1989 rename to share/zoneinfo/usno1989 diff --git a/commands/zoneinfo/usno1989a b/share/zoneinfo/usno1989a similarity index 100% rename from commands/zoneinfo/usno1989a rename to share/zoneinfo/usno1989a diff --git a/commands/zoneinfo/usno1995 b/share/zoneinfo/usno1995 similarity index 100% rename from commands/zoneinfo/usno1995 rename to share/zoneinfo/usno1995 diff --git a/commands/zoneinfo/usno1997 b/share/zoneinfo/usno1997 similarity index 100% rename from commands/zoneinfo/usno1997 rename to share/zoneinfo/usno1997 diff --git a/commands/zoneinfo/usno1998 b/share/zoneinfo/usno1998 similarity index 100% rename from commands/zoneinfo/usno1998 rename to share/zoneinfo/usno1998 diff --git a/commands/zoneinfo/workman.sh b/share/zoneinfo/workman.sh similarity index 100% rename from commands/zoneinfo/workman.sh rename to share/zoneinfo/workman.sh diff --git a/commands/zoneinfo/yearistype.sh b/share/zoneinfo/yearistype.sh similarity index 100% rename from commands/zoneinfo/yearistype.sh rename to share/zoneinfo/yearistype.sh diff --git a/commands/zoneinfo/zone.tab b/share/zoneinfo/zone.tab similarity index 100% rename from commands/zoneinfo/zone.tab rename to share/zoneinfo/zone.tab diff --git a/test/ipc/semctl/Makefile b/test/ipc/semctl/Makefile index 6fdccf7c3..354330a75 100644 --- a/test/ipc/semctl/Makefile +++ b/test/ipc/semctl/Makefile @@ -29,7 +29,7 @@ libipc.o: ../lib/libipc.c $(CC) $(CFLAGS) -c -o libipc.o ../lib/libipc.c clean: - /usr/bin/rm -f *.o $(PROG) + rm -f *.o $(PROG) test: sh ./test.sh diff --git a/test/ipc/semget/Makefile b/test/ipc/semget/Makefile index c1aa8f114..71d78ab24 100644 --- a/test/ipc/semget/Makefile +++ b/test/ipc/semget/Makefile @@ -29,7 +29,7 @@ libipc.o: ../lib/libipc.c $(CC) $(CFLAGS) -c -o libipc.o ../lib/libipc.c clean: - /usr/bin/rm -f *.o $(PROG) + rm -f *.o $(PROG) test: sh ./test.sh diff --git a/test/ipc/semop/Makefile b/test/ipc/semop/Makefile index 8089c5018..317230ee0 100644 --- a/test/ipc/semop/Makefile +++ b/test/ipc/semop/Makefile @@ -29,7 +29,7 @@ libipc.o: ../lib/libipc.c $(CC) $(CFLAGS) -c -o libipc.o ../lib/libipc.c clean: - /usr/bin/rm -f *.o $(PROG) + rm -f *.o $(PROG) test: sh ./test.sh diff --git a/test/ipc/shmat/Makefile b/test/ipc/shmat/Makefile index 146d4fc37..38fc72c00 100644 --- a/test/ipc/shmat/Makefile +++ b/test/ipc/shmat/Makefile @@ -29,7 +29,7 @@ libipc.o: ../lib/libipc.c $(CC) $(CFLAGS) -c -o libipc.o ../lib/libipc.c clean: - /usr/bin/rm -f *.o $(PROG) + rm -f *.o $(PROG) test: sh ./test.sh diff --git a/test/ipc/shmctl/Makefile b/test/ipc/shmctl/Makefile index 9799fc9d4..95215ae96 100644 --- a/test/ipc/shmctl/Makefile +++ b/test/ipc/shmctl/Makefile @@ -29,7 +29,7 @@ libipc.o: ../lib/libipc.c $(CC) $(CFLAGS) -c -o libipc.o ../lib/libipc.c clean: - /usr/bin/rm -f *.o $(PROG) + rm -f *.o $(PROG) test: sh ./test.sh diff --git a/test/ipc/shmdt/Makefile b/test/ipc/shmdt/Makefile index 34b4a8bf2..719667195 100644 --- a/test/ipc/shmdt/Makefile +++ b/test/ipc/shmdt/Makefile @@ -29,7 +29,7 @@ libipc.o: ../lib/libipc.c $(CC) $(CFLAGS) -c -o libipc.o ../lib/libipc.c clean: - /usr/bin/rm -f *.o $(PROG) + rm -f *.o $(PROG) test: sh ./test.sh diff --git a/test/ipc/shmget/Makefile b/test/ipc/shmget/Makefile index 99d6e903e..ae58b4581 100644 --- a/test/ipc/shmget/Makefile +++ b/test/ipc/shmget/Makefile @@ -29,7 +29,7 @@ libipc.o: ../lib/libipc.c $(CC) $(CFLAGS) -c -o libipc.o ../lib/libipc.c clean: - /usr/bin/rm -f *.o $(PROG) + rm -f *.o $(PROG) test: sh ./test.sh diff --git a/test/ipc/shmt/Makefile b/test/ipc/shmt/Makefile index e92d06cc7..858382727 100644 --- a/test/ipc/shmt/Makefile +++ b/test/ipc/shmt/Makefile @@ -18,7 +18,7 @@ test: sh testshm.sh clean: - /usr/bin/rm -f *.o $(PROG) + rm -f *.o $(PROG) shmt01: shmt01.c shmt02: shmt02.c diff --git a/test/select/Makefile b/test/select/Makefile index 08b0c3a58..13e319371 100644 --- a/test/select/Makefile +++ b/test/select/Makefile @@ -13,7 +13,7 @@ $(PROG): $(CC) $(CFLAGS) -o $@ $@.c -lutil clean: - /usr/bin/rm -f *.o $(PROG) + rm -f *.o $(PROG) speed: speed.c test00: test00.c diff --git a/test/testsh1.sh b/test/testsh1.sh index 6412290dc..10bdc61c5 100755 --- a/test/testsh1.sh +++ b/test/testsh1.sh @@ -45,16 +45,16 @@ cp passwd q if cmp -s p q; then : ; else echo Error on ar test 1; fi date >r ar r x.a p q r 2>/dev/null -ar r x.a /usr/bin/cp -ar r x.a /usr/bin/cat +ar r x.a /bin/cp +ar r x.a /bin/cat rm p q mv r R ar x x.a if cmp -s p /etc/passwd; then : ; else Error on ar test 2; fi if cmp -s q /etc/passwd; then : ; else Error on ar test 3; fi if cmp -s r R; then : ; else Error on ar test 4; fi -if cmp -s cp /usr/bin/cp; then : ; else Error on ar test 5; fi -if cmp -s cat /usr/bin/cat; then : ; else Error on ar test 6; fi +if cmp -s cp /bin/cp; then : ; else Error on ar test 5; fi +if cmp -s cat /bin/cat; then : ; else Error on ar test 6; fi rm cp cat p q r ar d x.a r >/dev/null ar x x.a diff --git a/tools/chrootmake.sh b/tools/chrootmake.sh index 98ce9f782..f973782da 100755 --- a/tools/chrootmake.sh +++ b/tools/chrootmake.sh @@ -3,7 +3,7 @@ set -e export SHELL=/bin/sh cd /usr/src make etcfiles -su bin -c 'make world' +make world cd tools rm revision rm /boot/image/* @@ -13,6 +13,6 @@ cp ../boot/boot /boot/boot cd /usr/src make clean # Let man find the manpages -su bin -c 'makewhatis /usr/man' -su bin -c 'makewhatis /usr/local/man' +makewhatis /usr/man +makewhatis /usr/local/man binsizes normal diff --git a/tools/release.sh b/tools/release.sh index 0936f9a7f..b4cb81aaa 100755 --- a/tools/release.sh +++ b/tools/release.sh @@ -259,8 +259,8 @@ mkdir -p $RELEASEPACKAGESOURCES echo " * Transfering bootstrap dirs to $RELEASEDIR" cp -p /bin/* /usr/bin/* $RELEASEDIR/$XBIN cp -rp /usr/lib $RELEASEDIR/usr -cp -rp /bin/bigsh /bin/sh /bin/echo $RELEASEDIR/bin -cp -rp /usr/bin/make /usr/bin/install /usr/bin/yacc /usr/bin/flex /usr/bin/asmconv $RELEASEDIR/usr/bin +cp -rp /bin/sh /bin/echo $RELEASEDIR/bin +cp -rp /usr/bin/make /usr/bin/install /usr/bin/yacc /usr/bin/lex /usr/bin/asmconv $RELEASEDIR/usr/bin if [ -d $PACKAGEDIR -a -d $PACKAGESOURCEDIR -a -f $PACKAGELIST -a -f $PACKAGESOURCELIST -a $PACKAGES -ne 0 ] then echo " * Transfering $PACKAGEDIR to $RELEASEPACKAGE" @@ -287,8 +287,8 @@ then echo " * Transfering $PACKAGEDIR to $RELEASEPACKAGE" done fi -# Make sure compilers and libraries are bin-owned -chown -R bin $RELEASEDIR/usr/lib +# Make sure compilers and libraries are root-owned +chown -R root $RELEASEDIR/usr/lib chmod -R u+w $RELEASEDIR/usr/lib if [ "$COPY" -ne 1 ] @@ -329,7 +329,7 @@ else fi echo " * Fixups for owners and modes of dirs and files" -chown -R bin $RELEASEDIR/usr/$SRC +chown -R root $RELEASEDIR/usr/$SRC chmod -R u+w $RELEASEDIR/usr/$SRC find $RELEASEDIR/usr/$SRC -type d | xargs chmod 755 find $RELEASEDIR/usr/$SRC -type f | xargs chmod 644 @@ -345,11 +345,10 @@ fi echo " * Bootstrap /etc/mk files" # Need /etc/mk in the new system to invoke make. Real ownerships # and permissions will be set by its own src/etc/Makefile. -# They have to be owned by bin so that the new make can do its work. mkdir -p $RELEASEDIR/etc/mk chmod 755 $RELEASEDIR/etc/mk cp $RELEASEDIR/usr/src/etc/mk/* $RELEASEDIR/etc/mk/ -chown -R bin $RELEASEDIR/etc/mk +chown -R root $RELEASEDIR/etc/mk echo " * Chroot build" cp chrootmake.sh $RELEASEDIR/usr/$SRC/tools/chrootmake.sh chroot $RELEASEDIR "PATH=/$XBIN sh -x /usr/$SRC/tools/chrootmake.sh" || exit 1 @@ -358,8 +357,8 @@ cp $RELEASEDIR/boot/image_big image echo " * Chroot build done" echo " * Removing bootstrap files" rm -rf $RELEASEDIR/$XBIN -# The build process leaves some file in $SRC as root. -chown -R bin $RELEASEDIR/usr/src* +# The build process leaves some file in $SRC as bin. +chown -R root $RELEASEDIR/usr/src* cp issue.install $RELEASEDIR/etc/issue if [ "$USB" -ne 0 ]